Merge lp:~jml/testtools/skip-dont-elide into lp:~testtools-committers/testtools/trunk
- skip-dont-elide
- Merge into trunk
Proposed by
Jonathan Lange
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 140 | ||||||||
Proposed branch: | lp:~jml/testtools/skip-dont-elide | ||||||||
Merge into: | lp:~testtools-committers/testtools/trunk | ||||||||
Diff against target: |
434 lines (+94/-93) 4 files modified
testtools/tests/__init__.py (+6/-20) testtools/tests/test_deferredruntest.py (+25/-19) testtools/tests/test_fixturesupport.py (+9/-3) testtools/tests/test_spinner.py (+54/-51) |
||||||||
To merge this branch: | bzr merge lp:~jml/testtools/skip-dont-elide | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
testtools developers | Pending | ||
Review via email: mp+42003@code.launchpad.net |
Commit message
Description of the change
This branch makes all of the tests that rely on fixtures or Twisted skip instead of not being included in the test run in the first place.
I don't know if there's a nicer way to do this.
To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'testtools/tests/__init__.py' | |||
2 | --- testtools/tests/__init__.py 2010-10-31 18:14:24 +0000 | |||
3 | +++ testtools/tests/__init__.py 2010-11-27 11:31:58 +0000 | |||
4 | @@ -10,10 +10,13 @@ | |||
5 | 10 | test_compat, | 10 | test_compat, |
6 | 11 | test_content, | 11 | test_content, |
7 | 12 | test_content_type, | 12 | test_content_type, |
8 | 13 | test_deferredruntest, | ||
9 | 14 | test_fixturesupport, | ||
10 | 13 | test_helpers, | 15 | test_helpers, |
11 | 14 | test_matchers, | 16 | test_matchers, |
12 | 15 | test_monkey, | 17 | test_monkey, |
13 | 16 | test_runtest, | 18 | test_runtest, |
14 | 19 | test_spinner, | ||
15 | 17 | test_testtools, | 20 | test_testtools, |
16 | 18 | test_testresult, | 21 | test_testresult, |
17 | 19 | test_testsuite, | 22 | test_testsuite, |
18 | @@ -23,34 +26,17 @@ | |||
19 | 23 | test_compat, | 26 | test_compat, |
20 | 24 | test_content, | 27 | test_content, |
21 | 25 | test_content_type, | 28 | test_content_type, |
22 | 29 | test_deferredruntest, | ||
23 | 30 | test_fixturesupport, | ||
24 | 26 | test_helpers, | 31 | test_helpers, |
25 | 27 | test_matchers, | 32 | test_matchers, |
26 | 28 | test_monkey, | 33 | test_monkey, |
27 | 29 | test_runtest, | 34 | test_runtest, |
28 | 35 | test_spinner, | ||
29 | 30 | test_testresult, | 36 | test_testresult, |
30 | 31 | test_testsuite, | 37 | test_testsuite, |
31 | 32 | test_testtools, | 38 | test_testtools, |
32 | 33 | ] | 39 | ] |
33 | 34 | try: | ||
34 | 35 | # Tests that rely on Twisted. | ||
35 | 36 | from testtools.tests import ( | ||
36 | 37 | test_deferredruntest, | ||
37 | 38 | test_spinner, | ||
38 | 39 | ) | ||
39 | 40 | except ImportError: | ||
40 | 41 | pass | ||
41 | 42 | else: | ||
42 | 43 | modules.extend([test_deferredruntest, test_spinner]) | ||
43 | 44 | try: | ||
44 | 45 | # Tests that rely on 'fixtures'. | ||
45 | 46 | from testtools.tests import ( | ||
46 | 47 | test_fixturesupport, | ||
47 | 48 | ) | ||
48 | 49 | except ImportError: | ||
49 | 50 | pass | ||
50 | 51 | else: | ||
51 | 52 | modules.extend([test_fixturesupport]) | ||
52 | 53 | |||
53 | 54 | for module in modules: | 40 | for module in modules: |
54 | 55 | suites.append(getattr(module, 'test_suite')()) | 41 | suites.append(getattr(module, 'test_suite')()) |
55 | 56 | return unittest.TestSuite(suites) | 42 | return unittest.TestSuite(suites) |
56 | 57 | 43 | ||
57 | === modified file 'testtools/tests/test_deferredruntest.py' | |||
58 | --- testtools/tests/test_deferredruntest.py 2010-11-12 11:30:23 +0000 | |||
59 | +++ testtools/tests/test_deferredruntest.py 2010-11-27 11:31:58 +0000 | |||
60 | @@ -12,12 +12,7 @@ | |||
61 | 12 | from testtools.content import ( | 12 | from testtools.content import ( |
62 | 13 | text_content, | 13 | text_content, |
63 | 14 | ) | 14 | ) |
70 | 15 | from testtools.deferredruntest import ( | 15 | from testtools.helpers import try_import |
65 | 16 | assert_fails_with, | ||
66 | 17 | AsynchronousDeferredRunTest, | ||
67 | 18 | flush_logged_errors, | ||
68 | 19 | SynchronousDeferredRunTest, | ||
69 | 20 | ) | ||
71 | 21 | from testtools.tests.helpers import ExtendedTestResult | 16 | from testtools.tests.helpers import ExtendedTestResult |
72 | 22 | from testtools.matchers import ( | 17 | from testtools.matchers import ( |
73 | 23 | Equals, | 18 | Equals, |
74 | @@ -26,9 +21,19 @@ | |||
75 | 26 | Raises, | 21 | Raises, |
76 | 27 | ) | 22 | ) |
77 | 28 | from testtools.runtest import RunTest | 23 | from testtools.runtest import RunTest |
81 | 29 | 24 | from testtools.tests.test_spinner import NeedsTwistedTestCase | |
82 | 30 | from twisted.internet import defer | 25 | |
83 | 31 | from twisted.python import failure, log | 26 | assert_fails_with = try_import('testtools.deferredruntest.assert_fails_with') |
84 | 27 | AsynchronousDeferredRunTest = try_import( | ||
85 | 28 | 'testtools.deferredruntest.AsynchronousDeferredRunTest') | ||
86 | 29 | flush_logged_errors = try_import( | ||
87 | 30 | 'testtools.deferredruntest.flush_logged_errors') | ||
88 | 31 | SynchronousDeferredRunTest = try_import( | ||
89 | 32 | 'testtools.deferredruntest.SynchronousDeferredRunTest') | ||
90 | 33 | |||
91 | 34 | defer = try_import('twisted.internet.defer') | ||
92 | 35 | failure = try_import('twisted.python.failure') | ||
93 | 36 | log = try_import('twisted.python.log') | ||
94 | 32 | 37 | ||
95 | 33 | 38 | ||
96 | 34 | class X(object): | 39 | class X(object): |
97 | @@ -77,7 +82,7 @@ | |||
98 | 77 | self.calls.append('test') | 82 | self.calls.append('test') |
99 | 78 | self.addCleanup(lambda: 1/0) | 83 | self.addCleanup(lambda: 1/0) |
100 | 79 | 84 | ||
102 | 80 | class TestIntegration(TestCase): | 85 | class TestIntegration(NeedsTwistedTestCase): |
103 | 81 | 86 | ||
104 | 82 | def assertResultsMatch(self, test, result): | 87 | def assertResultsMatch(self, test, result): |
105 | 83 | events = list(result._events) | 88 | events = list(result._events) |
106 | @@ -104,9 +109,9 @@ | |||
107 | 104 | from unittest import TestSuite | 109 | from unittest import TestSuite |
108 | 105 | from testtools import clone_test_with_new_id | 110 | from testtools import clone_test_with_new_id |
109 | 106 | runners = [ | 111 | runners = [ |
113 | 107 | RunTest, | 112 | ('RunTest', RunTest), |
114 | 108 | SynchronousDeferredRunTest, | 113 | ('SynchronousDeferredRunTest', SynchronousDeferredRunTest), |
115 | 109 | AsynchronousDeferredRunTest, | 114 | ('AsynchronousDeferredRunTest', AsynchronousDeferredRunTest), |
116 | 110 | ] | 115 | ] |
117 | 111 | 116 | ||
118 | 112 | tests = [ | 117 | tests = [ |
119 | @@ -118,12 +123,12 @@ | |||
120 | 118 | ] | 123 | ] |
121 | 119 | base_test = X.TestIntegration('test_runner') | 124 | base_test = X.TestIntegration('test_runner') |
122 | 120 | integration_tests = [] | 125 | integration_tests = [] |
124 | 121 | for runner in runners: | 126 | for runner_name, runner in runners: |
125 | 122 | for test in tests: | 127 | for test in tests: |
126 | 123 | new_test = clone_test_with_new_id( | 128 | new_test = clone_test_with_new_id( |
127 | 124 | base_test, '%s(%s, %s)' % ( | 129 | base_test, '%s(%s, %s)' % ( |
128 | 125 | base_test.id(), | 130 | base_test.id(), |
130 | 126 | runner.__name__, | 131 | runner_name, |
131 | 127 | test.__name__)) | 132 | test.__name__)) |
132 | 128 | new_test.test_factory = test | 133 | new_test.test_factory = test |
133 | 129 | new_test.runner = runner | 134 | new_test.runner = runner |
134 | @@ -131,7 +136,7 @@ | |||
135 | 131 | return TestSuite(integration_tests) | 136 | return TestSuite(integration_tests) |
136 | 132 | 137 | ||
137 | 133 | 138 | ||
139 | 134 | class TestSynchronousDeferredRunTest(TestCase): | 139 | class TestSynchronousDeferredRunTest(NeedsTwistedTestCase): |
140 | 135 | 140 | ||
141 | 136 | def make_result(self): | 141 | def make_result(self): |
142 | 137 | return ExtendedTestResult() | 142 | return ExtendedTestResult() |
143 | @@ -185,7 +190,7 @@ | |||
144 | 185 | ('stopTest', test)])) | 190 | ('stopTest', test)])) |
145 | 186 | 191 | ||
146 | 187 | 192 | ||
148 | 188 | class TestAsynchronousDeferredRunTest(TestCase): | 193 | class TestAsynchronousDeferredRunTest(NeedsTwistedTestCase): |
149 | 189 | 194 | ||
150 | 190 | def make_reactor(self): | 195 | def make_reactor(self): |
151 | 191 | from twisted.internet import reactor | 196 | from twisted.internet import reactor |
152 | @@ -602,10 +607,11 @@ | |||
153 | 602 | self.assertThat(error, KeysEqual('traceback', 'twisted-log')) | 607 | self.assertThat(error, KeysEqual('traceback', 'twisted-log')) |
154 | 603 | 608 | ||
155 | 604 | 609 | ||
157 | 605 | class TestAssertFailsWith(TestCase): | 610 | class TestAssertFailsWith(NeedsTwistedTestCase): |
158 | 606 | """Tests for `assert_fails_with`.""" | 611 | """Tests for `assert_fails_with`.""" |
159 | 607 | 612 | ||
161 | 608 | run_tests_with = SynchronousDeferredRunTest | 613 | if SynchronousDeferredRunTest is not None: |
162 | 614 | run_tests_with = SynchronousDeferredRunTest | ||
163 | 609 | 615 | ||
164 | 610 | def test_assert_fails_with_success(self): | 616 | def test_assert_fails_with_success(self): |
165 | 611 | # assert_fails_with fails the test if it's given a Deferred that | 617 | # assert_fails_with fails the test if it's given a Deferred that |
166 | 612 | 618 | ||
167 | === modified file 'testtools/tests/test_fixturesupport.py' | |||
168 | --- testtools/tests/test_fixturesupport.py 2010-10-28 20:18:39 +0000 | |||
169 | +++ testtools/tests/test_fixturesupport.py 2010-11-27 11:31:58 +0000 | |||
170 | @@ -1,20 +1,26 @@ | |||
171 | 1 | import unittest | 1 | import unittest |
172 | 2 | 2 | ||
173 | 3 | import fixtures | ||
174 | 4 | from fixtures.tests.helpers import LoggingFixture | ||
175 | 5 | |||
176 | 6 | from testtools import ( | 3 | from testtools import ( |
177 | 7 | TestCase, | 4 | TestCase, |
178 | 8 | content, | 5 | content, |
179 | 9 | content_type, | 6 | content_type, |
180 | 10 | ) | 7 | ) |
181 | 8 | from testtools.helpers import try_import | ||
182 | 11 | from testtools.tests.helpers import ( | 9 | from testtools.tests.helpers import ( |
183 | 12 | ExtendedTestResult, | 10 | ExtendedTestResult, |
184 | 13 | ) | 11 | ) |
185 | 14 | 12 | ||
186 | 13 | fixtures = try_import('fixtures') | ||
187 | 14 | LoggingFixture = try_import('fixtures.tests.helpers.LoggingFixture') | ||
188 | 15 | |||
189 | 15 | 16 | ||
190 | 16 | class TestFixtureSupport(TestCase): | 17 | class TestFixtureSupport(TestCase): |
191 | 17 | 18 | ||
192 | 19 | def setUp(self): | ||
193 | 20 | super(TestFixtureSupport, self).setUp() | ||
194 | 21 | if fixtures is None or LoggingFixture is None: | ||
195 | 22 | self.skipTest("Need fixtures") | ||
196 | 23 | |||
197 | 18 | def test_useFixture(self): | 24 | def test_useFixture(self): |
198 | 19 | fixture = LoggingFixture() | 25 | fixture = LoggingFixture() |
199 | 20 | class SimpleTest(TestCase): | 26 | class SimpleTest(TestCase): |
200 | 21 | 27 | ||
201 | === modified file 'testtools/tests/test_spinner.py' | |||
202 | --- testtools/tests/test_spinner.py 2010-11-11 09:46:18 +0000 | |||
203 | +++ testtools/tests/test_spinner.py 2010-11-27 11:31:58 +0000 | |||
204 | @@ -9,90 +9,91 @@ | |||
205 | 9 | skipIf, | 9 | skipIf, |
206 | 10 | TestCase, | 10 | TestCase, |
207 | 11 | ) | 11 | ) |
208 | 12 | from testtools.helpers import try_import | ||
209 | 12 | from testtools.matchers import ( | 13 | from testtools.matchers import ( |
210 | 13 | Equals, | 14 | Equals, |
211 | 14 | Is, | 15 | Is, |
212 | 15 | MatchesException, | 16 | MatchesException, |
213 | 16 | Raises, | 17 | Raises, |
214 | 17 | ) | 18 | ) |
232 | 18 | from testtools._spinner import ( | 19 | |
233 | 19 | DeferredNotFired, | 20 | _spinner = try_import('testtools._spinner') |
234 | 20 | extract_result, | 21 | |
235 | 21 | NoResultError, | 22 | defer = try_import('twisted.internet.defer') |
236 | 22 | not_reentrant, | 23 | Failure = try_import('twisted.python.failure.Failure') |
237 | 23 | ReentryError, | 24 | |
238 | 24 | Spinner, | 25 | |
239 | 25 | StaleJunkError, | 26 | class NeedsTwistedTestCase(TestCase): |
240 | 26 | TimeoutError, | 27 | |
241 | 27 | trap_unhandled_errors, | 28 | def setUp(self): |
242 | 28 | ) | 29 | super(NeedsTwistedTestCase, self).setUp() |
243 | 29 | 30 | if defer is None or Failure is None: | |
244 | 30 | from twisted.internet import defer | 31 | self.skipTest("Need Twisted to run") |
245 | 31 | from twisted.python.failure import Failure | 32 | |
246 | 32 | 33 | ||
247 | 33 | 34 | class TestNotReentrant(NeedsTwistedTestCase): | |
231 | 34 | class TestNotReentrant(TestCase): | ||
248 | 35 | 35 | ||
249 | 36 | def test_not_reentrant(self): | 36 | def test_not_reentrant(self): |
250 | 37 | # A function decorated as not being re-entrant will raise a | 37 | # A function decorated as not being re-entrant will raise a |
252 | 38 | # ReentryError if it is called while it is running. | 38 | # _spinner.ReentryError if it is called while it is running. |
253 | 39 | calls = [] | 39 | calls = [] |
255 | 40 | @not_reentrant | 40 | @_spinner.not_reentrant |
256 | 41 | def log_something(): | 41 | def log_something(): |
257 | 42 | calls.append(None) | 42 | calls.append(None) |
258 | 43 | if len(calls) < 5: | 43 | if len(calls) < 5: |
259 | 44 | log_something() | 44 | log_something() |
261 | 45 | self.assertThat(log_something, Raises(MatchesException(ReentryError))) | 45 | self.assertThat( |
262 | 46 | log_something, Raises(MatchesException(_spinner.ReentryError))) | ||
263 | 46 | self.assertEqual(1, len(calls)) | 47 | self.assertEqual(1, len(calls)) |
264 | 47 | 48 | ||
265 | 48 | def test_deeper_stack(self): | 49 | def test_deeper_stack(self): |
266 | 49 | calls = [] | 50 | calls = [] |
268 | 50 | @not_reentrant | 51 | @_spinner.not_reentrant |
269 | 51 | def g(): | 52 | def g(): |
270 | 52 | calls.append(None) | 53 | calls.append(None) |
271 | 53 | if len(calls) < 5: | 54 | if len(calls) < 5: |
272 | 54 | f() | 55 | f() |
274 | 55 | @not_reentrant | 56 | @_spinner.not_reentrant |
275 | 56 | def f(): | 57 | def f(): |
276 | 57 | calls.append(None) | 58 | calls.append(None) |
277 | 58 | if len(calls) < 5: | 59 | if len(calls) < 5: |
278 | 59 | g() | 60 | g() |
280 | 60 | self.assertThat(f, Raises(MatchesException(ReentryError))) | 61 | self.assertThat(f, Raises(MatchesException(_spinner.ReentryError))) |
281 | 61 | self.assertEqual(2, len(calls)) | 62 | self.assertEqual(2, len(calls)) |
282 | 62 | 63 | ||
283 | 63 | 64 | ||
285 | 64 | class TestExtractResult(TestCase): | 65 | class TestExtractResult(NeedsTwistedTestCase): |
286 | 65 | 66 | ||
287 | 66 | def test_not_fired(self): | 67 | def test_not_fired(self): |
292 | 67 | # extract_result raises DeferredNotFired if it's given a Deferred that | 68 | # _spinner.extract_result raises _spinner.DeferredNotFired if it's |
293 | 68 | # has not fired. | 69 | # given a Deferred that has not fired. |
294 | 69 | self.assertThat(lambda:extract_result(defer.Deferred()), | 70 | self.assertThat(lambda:_spinner.extract_result(defer.Deferred()), |
295 | 70 | Raises(MatchesException(DeferredNotFired))) | 71 | Raises(MatchesException(_spinner.DeferredNotFired))) |
296 | 71 | 72 | ||
297 | 72 | def test_success(self): | 73 | def test_success(self): |
300 | 73 | # extract_result returns the value of the Deferred if it has fired | 74 | # _spinner.extract_result returns the value of the Deferred if it has |
301 | 74 | # successfully. | 75 | # fired successfully. |
302 | 75 | marker = object() | 76 | marker = object() |
303 | 76 | d = defer.succeed(marker) | 77 | d = defer.succeed(marker) |
305 | 77 | self.assertThat(extract_result(d), Equals(marker)) | 78 | self.assertThat(_spinner.extract_result(d), Equals(marker)) |
306 | 78 | 79 | ||
307 | 79 | def test_failure(self): | 80 | def test_failure(self): |
310 | 80 | # extract_result raises the failure's exception if it's given a | 81 | # _spinner.extract_result raises the failure's exception if it's given |
311 | 81 | # Deferred that is failing. | 82 | # a Deferred that is failing. |
312 | 82 | try: | 83 | try: |
313 | 83 | 1/0 | 84 | 1/0 |
314 | 84 | except ZeroDivisionError: | 85 | except ZeroDivisionError: |
315 | 85 | f = Failure() | 86 | f = Failure() |
316 | 86 | d = defer.fail(f) | 87 | d = defer.fail(f) |
318 | 87 | self.assertThat(lambda:extract_result(d), | 88 | self.assertThat(lambda:_spinner.extract_result(d), |
319 | 88 | Raises(MatchesException(ZeroDivisionError))) | 89 | Raises(MatchesException(ZeroDivisionError))) |
320 | 89 | 90 | ||
321 | 90 | 91 | ||
323 | 91 | class TestTrapUnhandledErrors(TestCase): | 92 | class TestTrapUnhandledErrors(NeedsTwistedTestCase): |
324 | 92 | 93 | ||
325 | 93 | def test_no_deferreds(self): | 94 | def test_no_deferreds(self): |
326 | 94 | marker = object() | 95 | marker = object() |
328 | 95 | result, errors = trap_unhandled_errors(lambda: marker) | 96 | result, errors = _spinner.trap_unhandled_errors(lambda: marker) |
329 | 96 | self.assertEqual([], errors) | 97 | self.assertEqual([], errors) |
330 | 97 | self.assertIs(marker, result) | 98 | self.assertIs(marker, result) |
331 | 98 | 99 | ||
332 | @@ -105,12 +106,13 @@ | |||
333 | 105 | f = Failure() | 106 | f = Failure() |
334 | 106 | failures.append(f) | 107 | failures.append(f) |
335 | 107 | defer.fail(f) | 108 | defer.fail(f) |
337 | 108 | result, errors = trap_unhandled_errors(make_deferred_but_dont_handle) | 109 | result, errors = _spinner.trap_unhandled_errors( |
338 | 110 | make_deferred_but_dont_handle) | ||
339 | 109 | self.assertIs(None, result) | 111 | self.assertIs(None, result) |
340 | 110 | self.assertEqual(failures, [error.failResult for error in errors]) | 112 | self.assertEqual(failures, [error.failResult for error in errors]) |
341 | 111 | 113 | ||
342 | 112 | 114 | ||
344 | 113 | class TestRunInReactor(TestCase): | 115 | class TestRunInReactor(NeedsTwistedTestCase): |
345 | 114 | 116 | ||
346 | 115 | def make_reactor(self): | 117 | def make_reactor(self): |
347 | 116 | from twisted.internet import reactor | 118 | from twisted.internet import reactor |
348 | @@ -119,7 +121,7 @@ | |||
349 | 119 | def make_spinner(self, reactor=None): | 121 | def make_spinner(self, reactor=None): |
350 | 120 | if reactor is None: | 122 | if reactor is None: |
351 | 121 | reactor = self.make_reactor() | 123 | reactor = self.make_reactor() |
353 | 122 | return Spinner(reactor) | 124 | return _spinner.Spinner(reactor) |
354 | 123 | 125 | ||
355 | 124 | def make_timeout(self): | 126 | def make_timeout(self): |
356 | 125 | return 0.01 | 127 | return 0.01 |
357 | @@ -157,8 +159,8 @@ | |||
358 | 157 | # to run_in_reactor. | 159 | # to run_in_reactor. |
359 | 158 | spinner = self.make_spinner() | 160 | spinner = self.make_spinner() |
360 | 159 | self.assertThat(lambda: spinner.run( | 161 | self.assertThat(lambda: spinner.run( |
363 | 160 | self.make_timeout(), spinner.run, self.make_timeout(), lambda: None), | 162 | self.make_timeout(), spinner.run, self.make_timeout(), |
364 | 161 | Raises(MatchesException(ReentryError))) | 163 | lambda: None), Raises(MatchesException(_spinner.ReentryError))) |
365 | 162 | 164 | ||
366 | 163 | def test_deferred_value_returned(self): | 165 | def test_deferred_value_returned(self): |
367 | 164 | # If the given function returns a Deferred, run_in_reactor returns the | 166 | # If the given function returns a Deferred, run_in_reactor returns the |
368 | @@ -182,11 +184,12 @@ | |||
369 | 182 | self.assertEqual(new_hdlrs, map(signal.getsignal, signals)) | 184 | self.assertEqual(new_hdlrs, map(signal.getsignal, signals)) |
370 | 183 | 185 | ||
371 | 184 | def test_timeout(self): | 186 | def test_timeout(self): |
373 | 185 | # If the function takes too long to run, we raise a TimeoutError. | 187 | # If the function takes too long to run, we raise a |
374 | 188 | # _spinner.TimeoutError. | ||
375 | 186 | timeout = self.make_timeout() | 189 | timeout = self.make_timeout() |
376 | 187 | self.assertThat( | 190 | self.assertThat( |
377 | 188 | lambda:self.make_spinner().run(timeout, lambda: defer.Deferred()), | 191 | lambda:self.make_spinner().run(timeout, lambda: defer.Deferred()), |
379 | 189 | Raises(MatchesException(TimeoutError))) | 192 | Raises(MatchesException(_spinner.TimeoutError))) |
380 | 190 | 193 | ||
381 | 191 | def test_no_junk_by_default(self): | 194 | def test_no_junk_by_default(self): |
382 | 192 | # If the reactor hasn't spun yet, then there cannot be any junk. | 195 | # If the reactor hasn't spun yet, then there cannot be any junk. |
383 | @@ -263,7 +266,7 @@ | |||
384 | 263 | timeout = self.make_timeout() | 266 | timeout = self.make_timeout() |
385 | 264 | spinner.run(timeout, reactor.listenTCP, 0, ServerFactory()) | 267 | spinner.run(timeout, reactor.listenTCP, 0, ServerFactory()) |
386 | 265 | self.assertThat(lambda: spinner.run(timeout, lambda: None), | 268 | self.assertThat(lambda: spinner.run(timeout, lambda: None), |
388 | 266 | Raises(MatchesException(StaleJunkError))) | 269 | Raises(MatchesException(_spinner.StaleJunkError))) |
389 | 267 | 270 | ||
390 | 268 | def test_clear_junk_clears_previous_junk(self): | 271 | def test_clear_junk_clears_previous_junk(self): |
391 | 269 | # If 'run' is called and there's still junk in the spinner's junk | 272 | # If 'run' is called and there's still junk in the spinner's junk |
392 | @@ -279,7 +282,7 @@ | |||
393 | 279 | 282 | ||
394 | 280 | @skipIf(os.name != "posix", "Sending SIGINT with os.kill is posix only") | 283 | @skipIf(os.name != "posix", "Sending SIGINT with os.kill is posix only") |
395 | 281 | def test_sigint_raises_no_result_error(self): | 284 | def test_sigint_raises_no_result_error(self): |
397 | 282 | # If we get a SIGINT during a run, we raise NoResultError. | 285 | # If we get a SIGINT during a run, we raise _spinner.NoResultError. |
398 | 283 | SIGINT = getattr(signal, 'SIGINT', None) | 286 | SIGINT = getattr(signal, 'SIGINT', None) |
399 | 284 | if not SIGINT: | 287 | if not SIGINT: |
400 | 285 | self.skipTest("SIGINT not available") | 288 | self.skipTest("SIGINT not available") |
401 | @@ -288,19 +291,19 @@ | |||
402 | 288 | timeout = self.make_timeout() | 291 | timeout = self.make_timeout() |
403 | 289 | reactor.callLater(timeout, os.kill, os.getpid(), SIGINT) | 292 | reactor.callLater(timeout, os.kill, os.getpid(), SIGINT) |
404 | 290 | self.assertThat(lambda:spinner.run(timeout * 5, defer.Deferred), | 293 | self.assertThat(lambda:spinner.run(timeout * 5, defer.Deferred), |
406 | 291 | Raises(MatchesException(NoResultError))) | 294 | Raises(MatchesException(_spinner.NoResultError))) |
407 | 292 | self.assertEqual([], spinner._clean()) | 295 | self.assertEqual([], spinner._clean()) |
408 | 293 | 296 | ||
409 | 294 | @skipIf(os.name != "posix", "Sending SIGINT with os.kill is posix only") | 297 | @skipIf(os.name != "posix", "Sending SIGINT with os.kill is posix only") |
410 | 295 | def test_sigint_raises_no_result_error_second_time(self): | 298 | def test_sigint_raises_no_result_error_second_time(self): |
414 | 296 | # If we get a SIGINT during a run, we raise NoResultError. This test | 299 | # If we get a SIGINT during a run, we raise _spinner.NoResultError. |
415 | 297 | # is exactly the same as test_sigint_raises_no_result_error, and | 300 | # This test is exactly the same as test_sigint_raises_no_result_error, |
416 | 298 | # exists to make sure we haven't futzed with state. | 301 | # and exists to make sure we haven't futzed with state. |
417 | 299 | self.test_sigint_raises_no_result_error() | 302 | self.test_sigint_raises_no_result_error() |
418 | 300 | 303 | ||
419 | 301 | @skipIf(os.name != "posix", "Sending SIGINT with os.kill is posix only") | 304 | @skipIf(os.name != "posix", "Sending SIGINT with os.kill is posix only") |
420 | 302 | def test_fast_sigint_raises_no_result_error(self): | 305 | def test_fast_sigint_raises_no_result_error(self): |
422 | 303 | # If we get a SIGINT during a run, we raise NoResultError. | 306 | # If we get a SIGINT during a run, we raise _spinner.NoResultError. |
423 | 304 | SIGINT = getattr(signal, 'SIGINT', None) | 307 | SIGINT = getattr(signal, 'SIGINT', None) |
424 | 305 | if not SIGINT: | 308 | if not SIGINT: |
425 | 306 | self.skipTest("SIGINT not available") | 309 | self.skipTest("SIGINT not available") |
426 | @@ -309,7 +312,7 @@ | |||
427 | 309 | timeout = self.make_timeout() | 312 | timeout = self.make_timeout() |
428 | 310 | reactor.callWhenRunning(os.kill, os.getpid(), SIGINT) | 313 | reactor.callWhenRunning(os.kill, os.getpid(), SIGINT) |
429 | 311 | self.assertThat(lambda:spinner.run(timeout * 5, defer.Deferred), | 314 | self.assertThat(lambda:spinner.run(timeout * 5, defer.Deferred), |
431 | 312 | Raises(MatchesException(NoResultError))) | 315 | Raises(MatchesException(_spinner.NoResultError))) |
432 | 313 | self.assertEqual([], spinner._clean()) | 316 | self.assertEqual([], spinner._clean()) |
433 | 314 | 317 | ||
434 | 315 | @skipIf(os.name != "posix", "Sending SIGINT with os.kill is posix only") | 318 | @skipIf(os.name != "posix", "Sending SIGINT with os.kill is posix only") |
Seems fine enough to me.