Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
eamanu committed Feb 10, 2020
1 parent 44fa5f6 commit e486fe4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Lib/test/test_asyncio/test_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ def test_context_manager_no_yield(self):

self.assertFalse(lock.locked())

def test_lock_loop_not_running(self):
loop = asyncio.new_event_loop()
loop.stop()
with self.assertWarns(DeprecationWarning):
q = asyncio.Lock(loop=loop)


class EventTests(test_utils.TestCase):

Expand Down Expand Up @@ -483,6 +489,12 @@ async def c1(result):
self.assertTrue(t.done())
self.assertTrue(t.result())

def test_event_loop_not_running(self):
loop = asyncio.new_event_loop()
loop.stop()
with self.assertWarns(DeprecationWarning):
q = asyncio.Event(loop=loop)


class ConditionTests(test_utils.TestCase):

Expand Down Expand Up @@ -866,6 +878,12 @@ async def task_timeout():
with self.assertWarns(DeprecationWarning):
loop.run_until_complete(task_timeout())

def test_condition_loop_not_running(self):
loop = asyncio.new_event_loop()
loop.stop()
with self.assertWarns(DeprecationWarning):
q = asyncio.Condition(loop=loop)


class SemaphoreTests(test_utils.TestCase):

Expand Down Expand Up @@ -1096,6 +1114,12 @@ def test_context_manager_no_yield(self):

self.assertEqual(2, sem._value)

def test_semaphore_loop_not_running(self):
loop = asyncio.new_event_loop()
loop.stop()
with self.assertWarns(DeprecationWarning):
q = asyncio.Semaphore(loop=loop)


if __name__ == '__main__':
unittest.main()
6 changes: 6 additions & 0 deletions Lib/test/test_asyncio/test_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ async def test():
loop.run_until_complete(test())
self.assertAlmostEqual(0.02, loop.time())

def test_queue_loop_not_running(self):
loop = asyncio.new_event_loop()
loop.stop()
with self.assertWarns(DeprecationWarning):
q = asyncio.Queue(loop=loop)


class QueueGetTests(_QueueTestBase):

Expand Down

0 comments on commit e486fe4

Please sign in to comment.