Merge pull request #1148 from cjwatson/8267-circular-reporter

Fix circular import in twisted.trial.reporter
This commit is contained in:
Tom Most 2019-07-21 19:05:39 -07:00 committed by GitHub
commit a4c171b461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -0,0 +1 @@
Fixed circular import in twisted.trial.reporter, introduced in Twisted 16.0.0.

View File

@ -26,7 +26,6 @@ from twisted.python.failure import Failure
from twisted.python.util import untilConcludes
from twisted.python.compat import _PY3, items
from twisted.trial import itrial, util
from twisted.trial.unittest import makeTodo
try:
from subunit import TestProtocolClient
@ -35,6 +34,23 @@ except ImportError:
def _makeTodo(value):
"""
Return a L{Todo} object built from C{value}.
This is a synonym for L{twisted.trial.unittest.makeTodo}, but imported
locally to avoid circular imports.
@param value: A string or a tuple of C{(errors, reason)}, where C{errors}
is either a single exception class or an iterable of exception classes.
@return: A L{Todo} object.
"""
from twisted.trial.unittest import makeTodo
return makeTodo(value)
class BrokenTestCaseWarning(Warning):
"""
Emitted as a warning when an exception occurs in one of setUp or tearDown.
@ -170,7 +186,7 @@ class TestResult(pyunit.TestResult, object):
message is provided.
"""
if todo is None:
todo = makeTodo(self._DEFAULT_TODO)
todo = _makeTodo(self._DEFAULT_TODO)
self.unexpectedSuccesses.append((test, todo))
@ -187,7 +203,7 @@ class TestResult(pyunit.TestResult, object):
message is provided.
"""
if todo is None:
todo = makeTodo(self._DEFAULT_TODO)
todo = _makeTodo(self._DEFAULT_TODO)
self.expectedFailures.append((test, error, todo))