diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-06-18 02:25:23 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-06-18 02:25:23 +0200 |
commit | fa61d94bb23d74924ca9bb8883ec0ce97ecadc94 (patch) | |
tree | 34c158727dc915a4f4d1ce1e727a52fe927ab8e0 /tests/test_locks.py | |
parent | f3635798328eebea3726a329ab28b33eac951c28 (diff) | |
parent | 830f91fafb1f2b2ea4be28be6fd8bac9bed53dd4 (diff) | |
download | trollius-fa61d94bb23d74924ca9bb8883ec0ce97ecadc94.tar.gz |
Merge with Tulip
Diffstat (limited to 'tests/test_locks.py')
-rw-r--r-- | tests/test_locks.py | 60 |
1 files changed, 16 insertions, 44 deletions
diff --git a/tests/test_locks.py b/tests/test_locks.py index 6ba0b62..78e6254 100644 --- a/tests/test_locks.py +++ b/tests/test_locks.py @@ -21,11 +21,7 @@ RGX_REPR = re.compile(STR_RGX_REPR) class LockTests(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_ctor_loop(self): loop = mock.Mock() @@ -36,12 +32,9 @@ class LockTests(test_utils.TestCase): self.assertIs(lock._loop, self.loop) def test_ctor_noloop(self): - try: - asyncio.set_event_loop(self.loop) - lock = asyncio.Lock() - self.assertIs(lock._loop, self.loop) - finally: - asyncio.set_event_loop(None) + asyncio.set_event_loop(self.loop) + lock = asyncio.Lock() + self.assertIs(lock._loop, self.loop) def test_repr(self): lock = asyncio.Lock(loop=self.loop) @@ -245,11 +238,7 @@ class LockTests(test_utils.TestCase): class EventTests(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_ctor_loop(self): loop = mock.Mock() @@ -260,12 +249,9 @@ class EventTests(test_utils.TestCase): self.assertIs(ev._loop, self.loop) def test_ctor_noloop(self): - try: - asyncio.set_event_loop(self.loop) - ev = asyncio.Event() - self.assertIs(ev._loop, self.loop) - finally: - asyncio.set_event_loop(None) + asyncio.set_event_loop(self.loop) + ev = asyncio.Event() + self.assertIs(ev._loop, self.loop) def test_repr(self): ev = asyncio.Event(loop=self.loop) @@ -381,11 +367,7 @@ class EventTests(test_utils.TestCase): class ConditionTests(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_ctor_loop(self): loop = mock.Mock() @@ -396,12 +378,9 @@ class ConditionTests(test_utils.TestCase): self.assertIs(cond._loop, self.loop) def test_ctor_noloop(self): - try: - asyncio.set_event_loop(self.loop) - cond = asyncio.Condition() - self.assertIs(cond._loop, self.loop) - finally: - asyncio.set_event_loop(None) + asyncio.set_event_loop(self.loop) + cond = asyncio.Condition() + self.assertIs(cond._loop, self.loop) def test_wait(self): cond = asyncio.Condition(loop=self.loop) @@ -686,11 +665,7 @@ class ConditionTests(test_utils.TestCase): class SemaphoreTests(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_ctor_loop(self): loop = mock.Mock() @@ -701,12 +676,9 @@ class SemaphoreTests(test_utils.TestCase): self.assertIs(sem._loop, self.loop) def test_ctor_noloop(self): - try: - asyncio.set_event_loop(self.loop) - sem = asyncio.Semaphore() - self.assertIs(sem._loop, self.loop) - finally: - asyncio.set_event_loop(None) + asyncio.set_event_loop(self.loop) + sem = asyncio.Semaphore() + self.assertIs(sem._loop, self.loop) def test_initial_value_zero(self): sem = asyncio.Semaphore(0, loop=self.loop) |