@@ -25,7 +25,7 @@ provides useful fixtures and markers to make testing easier.
25
25
@pytest.mark.asyncio
26
26
async def test_some_asyncio_code ():
27
27
res = await library.do_something()
28
- assert b ' expected result' == res
28
+ assert b " expected result" == res
29
29
30
30
pytest-asyncio has been strongly influenced by pytest-tornado _.
31
31
@@ -139,9 +139,9 @@ Use ``pytest.mark.asyncio`` for this purpose.
139
139
.. code-block :: python
140
140
141
141
def test_http_client (event_loop ):
142
- url = ' http://httpbin.org/get'
142
+ url = " http://httpbin.org/get"
143
143
resp = event_loop.run_until_complete(http_client(url))
144
- assert b ' HTTP/1.1 200 OK' in resp
144
+ assert b " HTTP/1.1 200 OK" in resp
145
145
146
146
This fixture can be easily overridden in any of the standard pytest locations
147
147
(e.g. directly in the test file, or in ``conftest.py ``) to use a non-default
@@ -189,12 +189,14 @@ Asynchronous fixtures are defined just like ordinary pytest fixtures, except the
189
189
190
190
import pytest_asyncio
191
191
192
+
192
193
@pytest_asyncio.fixture
193
194
async def async_gen_fixture():
194
195
await asyncio.sleep(0.1)
195
- yield 'a value'
196
+ yield "a value"
197
+
196
198
197
- @pytest_asyncio.fixture(scope=' module' )
199
+ @pytest_asyncio.fixture(scope=" module" )
198
200
async def async_fixture():
199
201
return await asyncio.sleep(0.1)
200
202
@@ -227,11 +229,13 @@ Only test coroutines will be affected (by default, coroutines prefixed by
227
229
.. code-block :: python
228
230
229
231
import asyncio
232
+
230
233
import pytest
231
234
232
235
# All test coroutines will be treated as marked.
233
236
pytestmark = pytest.mark.asyncio
234
237
238
+
235
239
async def test_example (event_loop ):
236
240
""" No marker!"""
237
241
await asyncio.sleep(0 , loop = event_loop)
0 commit comments