Skip to content

Commit 16cc19d

Browse files
committed
handle case when no event loop exists (add test)
1 parent 0e1132c commit 16cc19d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/test_simple.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
@asyncio.coroutine
10-
def async_coro(loop):
10+
def async_coro(loop=None):
1111
"""A very simple coroutine."""
1212
yield from asyncio.sleep(0, loop=loop)
1313
return 'ok'
@@ -143,3 +143,18 @@ def test_asyncio_marker_method(self, event_loop):
143143
"""Test the asyncio pytest marker in a Test class."""
144144
ret = yield from async_coro(event_loop)
145145
assert ret == 'ok'
146+
147+
148+
class TestUnexistingLoop:
149+
@pytest.fixture
150+
def remove_loop(self):
151+
old_loop = asyncio.get_event_loop()
152+
asyncio.set_event_loop(None)
153+
yield
154+
asyncio.set_event_loop(old_loop)
155+
156+
@pytest.mark.asyncio
157+
def test_asyncio_marker_without_loop(self, remove_loop):
158+
"""Test the asyncio pytest marker in a Test class."""
159+
ret = yield from async_coro()
160+
assert ret == 'ok'

0 commit comments

Comments
 (0)