Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: third_party/twisted_8_1/twisted/trial/test/test_keyboard.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 import StringIO
2 from twisted.trial import unittest
3 from twisted.trial import reporter, runner
4
5
6 class TrialTest(unittest.TestCase):
7 def setUp(self):
8 self.output = StringIO.StringIO()
9 self.reporter = reporter.TestResult()
10 self.loader = runner.TestLoader()
11
12
13 class TestInterruptInTest(TrialTest):
14 class InterruptedTest(unittest.TestCase):
15 def test_02_raiseInterrupt(self):
16 raise KeyboardInterrupt
17
18 def test_01_doNothing(self):
19 pass
20
21 def test_03_doNothing(self):
22 TestInterruptInTest.test_03_doNothing_run = True
23
24 def setUp(self):
25 super(TestInterruptInTest, self).setUp()
26 self.suite = self.loader.loadClass(TestInterruptInTest.InterruptedTest)
27 TestInterruptInTest.test_03_doNothing_run = None
28
29 def test_setUpOK(self):
30 self.failUnlessEqual(3, self.suite.countTestCases())
31 self.failUnlessEqual(0, self.reporter.testsRun)
32 self.failIf(self.reporter.shouldStop)
33
34 def test_interruptInTest(self):
35 runner.TrialSuite([self.suite]).run(self.reporter)
36 self.failUnless(self.reporter.shouldStop)
37 self.failUnlessEqual(2, self.reporter.testsRun)
38 self.failIf(TestInterruptInTest.test_03_doNothing_run,
39 "test_03_doNothing ran.")
40
41
42 class TestInterruptInSetUp(TrialTest):
43 testsRun = 0
44
45 class InterruptedTest(unittest.TestCase):
46 def setUp(self):
47 if TestInterruptInSetUp.testsRun > 0:
48 raise KeyboardInterrupt
49
50 def test_01(self):
51 TestInterruptInSetUp.testsRun += 1
52
53 def test_02(self):
54 TestInterruptInSetUp.testsRun += 1
55 TestInterruptInSetUp.test_02_run = True
56
57 def setUp(self):
58 super(TestInterruptInSetUp, self).setUp()
59 self.suite = self.loader.loadClass(
60 TestInterruptInSetUp.InterruptedTest)
61 TestInterruptInSetUp.test_02_run = False
62 TestInterruptInSetUp.testsRun = 0
63
64 def test_setUpOK(self):
65 self.failUnlessEqual(0, TestInterruptInSetUp.testsRun)
66 self.failUnlessEqual(2, self.suite.countTestCases())
67 self.failUnlessEqual(0, self.reporter.testsRun)
68 self.failIf(self.reporter.shouldStop)
69
70 def test_interruptInSetUp(self):
71 runner.TrialSuite([self.suite]).run(self.reporter)
72 self.failUnless(self.reporter.shouldStop)
73 self.failUnlessEqual(2, self.reporter.testsRun)
74 self.failIf(TestInterruptInSetUp.test_02_run,
75 "test_02 ran")
76
77
78 class TestInterruptInTearDown(TrialTest):
79 testsRun = 0
80
81 class InterruptedTest(unittest.TestCase):
82 def tearDown(self):
83 if TestInterruptInTearDown.testsRun > 0:
84 raise KeyboardInterrupt
85
86 def test_01(self):
87 TestInterruptInTearDown.testsRun += 1
88
89 def test_02(self):
90 TestInterruptInTearDown.testsRun += 1
91 TestInterruptInTearDown.test_02_run = True
92
93 def setUp(self):
94 super(TestInterruptInTearDown, self).setUp()
95 self.suite = self.loader.loadClass(
96 TestInterruptInTearDown.InterruptedTest)
97 TestInterruptInTearDown.testsRun = 0
98 TestInterruptInTearDown.test_02_run = False
99
100 def test_setUpOK(self):
101 self.failUnlessEqual(0, TestInterruptInTearDown.testsRun)
102 self.failUnlessEqual(2, self.suite.countTestCases())
103 self.failUnlessEqual(0, self.reporter.testsRun)
104 self.failIf(self.reporter.shouldStop)
105
106 def test_interruptInTearDown(self):
107 runner.TrialSuite([self.suite]).run(self.reporter)
108 self.failUnlessEqual(1, self.reporter.testsRun)
109 self.failUnless(self.reporter.shouldStop)
110 self.failIf(TestInterruptInTearDown.test_02_run,
111 "test_02 ran")
112
113
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/trial/test/test_doctest.py ('k') | third_party/twisted_8_1/twisted/trial/test/test_loader.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698