diff --git a/Lib/unittest/test/test_break.py b/Lib/unittest/test/test_break.py index aa2c69eea01..eebd2b610ce 100644 --- a/Lib/unittest/test/test_break.py +++ b/Lib/unittest/test/test_break.py @@ -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) diff --git a/Misc/NEWS.d/next/Tests/2018-06-19-17-55-46.bpo-33746.Sz7avn.rst b/Misc/NEWS.d/next/Tests/2018-06-19-17-55-46.bpo-33746.Sz7avn.rst new file mode 100644 index 00000000000..e79399f03be --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2018-06-19-17-55-46.bpo-33746.Sz7avn.rst @@ -0,0 +1 @@ +Fix test_unittest when run in verbose mode.