def testRegisterResult(self): result = unittest.TestResult() self.assertNotIn(result, unittest.signals._results) unittest.registerResult(result) try: self.assertIn(result, unittest.signals._results) finally: unittest.removeResult(result)
def testRemoveResult(self): result = unittest.TestResult() unittest.registerResult(result) unittest.installHandler() self.assertTrue(unittest.removeResult(result)) self.assertFalse(unittest.removeResult(unittest.TestResult())) try: pid = os.getpid() os.kill(pid, signal.SIGINT) except KeyboardInterrupt: pass self.assertFalse(result.shouldStop)
def run(self, test): # Write TAP header. The testplan does not have to be at the beginning, # but it is better since this way the consumer knows how many have not # been run. To see specs of TAP: # https://testanything.org/tap-specification.html num_tests = test.countTestCases() self.stream.write("TAP version 13\n1..{}\n".format(num_tests)) self.stream.flush() result = TapTestResult(self.stream) unittest.registerResult(result) test(result) unittest.removeResult(result) return result
def testRemoveResult(self): if due_to_ironpython_bug("http://ironpython.codeplex.com/workitem/28171"): return result = unittest.TestResult() unittest.registerResult(result) unittest.installHandler() self.assertTrue(unittest.removeResult(result)) # Should this raise an error instead? self.assertFalse(unittest.removeResult(unittest.TestResult())) try: pid = os.getpid() os.kill(pid, signal.SIGINT) except KeyboardInterrupt: pass self.assertFalse(result.shouldStop)