Skip to content

Commit

Permalink
Merge pull request #1148 from cjwatson/8267-circular-reporter
Browse files Browse the repository at this point in the history
Fix circular import in twisted.trial.reporter
  • Loading branch information
twm committed Jul 22, 2019
2 parents ab6156f + 6e3c05c commit a4c171b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/twisted/newsfragments/8267.bugfix
@@ -0,0 +1 @@
Fixed circular import in twisted.trial.reporter, introduced in Twisted 16.0.0.
22 changes: 19 additions & 3 deletions src/twisted/trial/reporter.py
Expand Up @@ -26,7 +26,6 @@
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
Expand All @@ -35,6 +34,23 @@



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.
Expand Down Expand Up @@ -170,7 +186,7 @@ def addUnexpectedSuccess(self, test, todo=None):
message is provided.
"""
if todo is None:
todo = makeTodo(self._DEFAULT_TODO)
todo = _makeTodo(self._DEFAULT_TODO)
self.unexpectedSuccesses.append((test, todo))


Expand All @@ -187,7 +203,7 @@ def addExpectedFailure(self, test, error, todo=None):
message is provided.
"""
if todo is None:
todo = makeTodo(self._DEFAULT_TODO)
todo = _makeTodo(self._DEFAULT_TODO)
self.expectedFailures.append((test, error, todo))


Expand Down

0 comments on commit a4c171b

Please sign in to comment.