Skip to content

Commit

Permalink
There's no reason to use private unittest classes
Browse files Browse the repository at this point in the history
The only reason to import _UnexpectedSuccess is to format an exception
message, and we can use any class we want for that.
  • Loading branch information
mgedmin committed Dec 28, 2016
1 parent e5636d1 commit e04cb43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions src/zope/testrunner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,8 @@
# Python 3
import queue as Queue # Python 3

try:
from unittest import _UnexpectedSuccess # Python 3.1
except ImportError:
try:
from unittest.case import _UnexpectedSuccess # Python 2.7 and 3.2
except ImportError:
class _UnexpectedSuccess(Exception):
pass
class UnexpectedSuccess(Exception):
pass


PYREFCOUNT_PATTERN = re.compile('\[[0-9]+ refs\]')
Expand Down Expand Up @@ -825,8 +819,9 @@ def addExpectedFailure(self, test, exc_info):
unittest.TestResult.addExpectedFailure(self, test, exc_info)

def addUnexpectedSuccess(self, test):
self.options.output.test_error(test, time.time() - self._start_time,
(_UnexpectedSuccess, None, None))
self.options.output.test_error(
test, time.time() - self._start_time,
(UnexpectedSuccess, UnexpectedSuccess(), None))

unittest.TestResult.addUnexpectedSuccess(self, test)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ affecting the Python path:
<BLANKLINE>
Error in test test_ef (sampletestsf.TestUnexpectedSuccess)
Traceback (most recent call last):
..._UnexpectedSuccess
...UnexpectedSuccess
<BLANKLINE>
Ran 1 tests with 1 failures, 0 errors and 0 skipped in N.NNN seconds.
Tearing down left over layers:
Expand Down

0 comments on commit e04cb43

Please sign in to comment.