/usr/lib/python3/dist-packages/twisted/trial/test
NameSizeModeActions
__pycache__/-0755rm
detests.py56670644editdlrm
erroneous.py47920644editdlrm
mockcustomsuite.py5360644editdlrm
mockcustomsuite2.py5330644editdlrm
mockcustomsuite3.py6760644editdlrm
mockdoctest.py24210644editdlrm
moduleself.py1700644editdlrm
moduletest.py3020644editdlrm
novars.py1820644editdlrm
ordertests.py8640644editdlrm
packages.py46510644editdlrm
sample.py20840644editdlrm
scripttest.py4570755editdlrm
skipping.py57090644editdlrm
suppression.py24990644editdlrm
test_assertions.py608130644editdlrm
test_asyncassertions.py25520644editdlrm
test_deferred.py88220644editdlrm
test_doctest.py17130644editdlrm
test_keyboard.py37840644editdlrm
test_loader.py223600644editdlrm
test_log.py80400644editdlrm
test_output.py50160644editdlrm
test_plugins.py14600644editdlrm
test_pyunitcompat.py76200644editdlrm
test_reporter.py567090644editdlrm
test_runner.py350400644editdlrm
test_script.py293770644editdlrm
test_skip.py26510644editdlrm
test_suppression.py59110644editdlrm
test_testcase.py19850644editdlrm
test_tests.py495000644editdlrm
test_util.py196600644editdlrm
test_warning.py176380644editdlrm
weird.py6750644editdlrm
__init__.py1300644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/trial/test/test_keyboard.py (3784B)
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Tests for interrupting tests with Control-C. """ from io import StringIO from twisted.trial import reporter, runner, unittest class TrialTest(unittest.SynchronousTestCase): def setUp(self): self.output = StringIO() self.reporter = reporter.TestResult() self.loader = runner.TestLoader() class InterruptInTestTests(TrialTest): class InterruptedTest(unittest.TestCase): def test_02_raiseInterrupt(self): raise KeyboardInterrupt def test_01_doNothing(self): pass def test_03_doNothing(self): InterruptInTestTests.test_03_doNothing_run = True def setUp(self): super().setUp() self.suite = self.loader.loadClass(InterruptInTestTests.InterruptedTest) InterruptInTestTests.test_03_doNothing_run = None def test_setUpOK(self): self.assertEqual(3, self.suite.countTestCases()) self.assertEqual(0, self.reporter.testsRun) self.assertFalse(self.reporter.shouldStop) def test_interruptInTest(self): runner.TrialSuite([self.suite]).run(self.reporter) self.assertTrue(self.reporter.shouldStop) self.assertEqual(2, self.reporter.testsRun) self.assertFalse( InterruptInTestTests.test_03_doNothing_run, "test_03_doNothing ran." ) class InterruptInSetUpTests(TrialTest): testsRun = 0 class InterruptedTest(unittest.TestCase): def setUp(self): if InterruptInSetUpTests.testsRun > 0: raise KeyboardInterrupt def test_01(self): InterruptInSetUpTests.testsRun += 1 def test_02(self): InterruptInSetUpTests.testsRun += 1 InterruptInSetUpTests.test_02_run = True def setUp(self): super().setUp() self.suite = self.loader.loadClass(InterruptInSetUpTests.InterruptedTest) InterruptInSetUpTests.test_02_run = False InterruptInSetUpTests.testsRun = 0 def test_setUpOK(self): self.assertEqual(0, InterruptInSetUpTests.testsRun) self.assertEqual(2, self.suite.countTestCases()) self.assertEqual(0, self.reporter.testsRun) self.assertFalse(self.reporter.shouldStop) def test_interruptInSetUp(self): runner.TrialSuite([self.suite]).run(self.reporter) self.assertTrue(self.reporter.shouldStop) self.assertEqual(2, self.reporter.testsRun) self.assertFalse(InterruptInSetUpTests.test_02_run, "test_02 ran") class InterruptInTearDownTests(TrialTest): testsRun = 0 class InterruptedTest(unittest.TestCase): def tearDown(self): if InterruptInTearDownTests.testsRun > 0: raise KeyboardInterrupt def test_01(self): InterruptInTearDownTests.testsRun += 1 def test_02(self): InterruptInTearDownTests.testsRun += 1 InterruptInTearDownTests.test_02_run = True def setUp(self): super().setUp() self.suite = self.loader.loadClass(InterruptInTearDownTests.InterruptedTest) InterruptInTearDownTests.testsRun = 0 InterruptInTearDownTests.test_02_run = False def test_setUpOK(self): self.assertEqual(0, InterruptInTearDownTests.testsRun) self.assertEqual(2, self.suite.countTestCases()) self.assertEqual(0, self.reporter.testsRun) self.assertFalse(self.reporter.shouldStop) def test_interruptInTearDown(self): runner.TrialSuite([self.suite]).run(self.reporter) self.assertEqual(1, self.reporter.testsRun) self.assertTrue(self.reporter.shouldStop) self.assertFalse(InterruptInTearDownTests.test_02_run, "test_02 ran")