diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2014-06-17 23:36:32 (GMT) |
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2014-06-17 23:36:32 (GMT) |
| commit | c73701de7292b7de0fee5b7f82a610d7515c18a4 (patch) | |
| tree | 18db9589cbd8880f4b1ac411bf675de788740e34 /Lib/test/test_asyncio/test_futures.py | |
| parent | d6f02fc649d2e248f2e7b418771371db2b6637a2 (diff) | |
| download | cpython-c73701de7292b7de0fee5b7f82a610d7515c18a4.zip cpython-c73701de7292b7de0fee5b7f82a610d7515c18a4.tar.gz cpython-c73701de7292b7de0fee5b7f82a610d7515c18a4.tar.bz2 | |
asyncio: Refactor tests: add a base TestCase class
Diffstat (limited to 'Lib/test/test_asyncio/test_futures.py')
| -rw-r--r-- | Lib/test/test_asyncio/test_futures.py | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py index 399e8f4..a230d61 100644 --- a/Lib/test/test_asyncio/test_futures.py +++ b/Lib/test/test_asyncio/test_futures.py @@ -13,14 +13,10 @@ def _fakefunc(f): return f -class FutureTests(unittest.TestCase): +class FutureTests(test_utils.TestCase): def setUp(self): - self.loop = test_utils.TestLoop() - asyncio.set_event_loop(None) - - def tearDown(self): - self.loop.close() + self.loop = self.new_test_loop() def test_initial_state(self): f = asyncio.Future(loop=self.loop) @@ -30,12 +26,9 @@ class FutureTests(unittest.TestCase): self.assertTrue(f.cancelled()) def test_init_constructor_default_loop(self): - try: - asyncio.set_event_loop(self.loop) - f = asyncio.Future() - self.assertIs(f._loop, self.loop) - finally: - asyncio.set_event_loop(None) + asyncio.set_event_loop(self.loop) + f = asyncio.Future() + self.assertIs(f._loop, self.loop) def test_constructor_positional(self): # Make sure Future doesn't accept a positional argument @@ -264,14 +257,10 @@ class FutureTests(unittest.TestCase): self.assertTrue(f2.cancelled()) -class FutureDoneCallbackTests(unittest.TestCase): +class FutureDoneCallbackTests(test_utils.TestCase): def setUp(self): - self.loop = test_utils.TestLoop() - asyncio.set_event_loop(None) - - def tearDown(self): - self.loop.close() + self.loop = self.new_test_loop() def run_briefly(self): test_utils.run_briefly(self.loop) |
