Commit fd8fbce4 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

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.
parent 9bb92235
......@@ -39,16 +39,13 @@ class TestBreak(unittest.TestCase):
def testRegisterResult(self):
result = unittest.TestResult()
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")
self.assertNotIn(result, unittest.signals._results)
unittest.registerResult(result)
try:
self.assertIn(result, unittest.signals._results)
finally:
unittest.removeResult(result)
def testInterruptCaught(self):
default_handler = signal.getsignal(signal.SIGINT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment