mirror of https://github.com/python/cpython
bpo-33746: Fix test_unittest.testRegisterResult() in verbose mode (GH-7799)
Only make sure that the result is in unittest.signals._results, don't check the full content of unittest.signals._results. support._run_suite() uses TextTestRunner in verbose mode, but TextTestRunner.run() calls registerResult(result) which made the test fail with "odd object in result set". Call also removeResult() to restore unittest.signals._results to avoid test side effect.
This commit is contained in:
parent
9bb92235f6
commit
fd8fbce495
|
@ -39,16 +39,13 @@ class TestBreak(unittest.TestCase):
|
|||
|
||||
def testRegisterResult(self):
|
||||
result = unittest.TestResult()
|
||||
self.assertNotIn(result, unittest.signals._results)
|
||||
|
||||
unittest.registerResult(result)
|
||||
|
||||
for ref in unittest.signals._results:
|
||||
if ref is result:
|
||||
break
|
||||
elif ref is not result:
|
||||
self.fail("odd object in result set")
|
||||
else:
|
||||
self.fail("result not found")
|
||||
|
||||
try:
|
||||
self.assertIn(result, unittest.signals._results)
|
||||
finally:
|
||||
unittest.removeResult(result)
|
||||
|
||||
def testInterruptCaught(self):
|
||||
default_handler = signal.getsignal(signal.SIGINT)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix test_unittest when run in verbose mode.
|
Loading…
Reference in New Issue