File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ Features
42
42
- fixtures for injecting unused tcp ports
43
43
- pytest markers for treating tests as asyncio coroutines
44
44
- easy testing with non-default event loops
45
-
45
+ - support of ` async def ` fixtures and async generator fixtures
46
46
47
47
Installation
48
48
------------
@@ -122,6 +122,23 @@ when several unused TCP ports are required in a test.
122
122
port1, port2 = unused_tcp_port_factory(), unused_tcp_port_factory()
123
123
...
124
124
125
+ ``async fixtures ``
126
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127
+ This fixtures may be defined as common pytest fixture:
128
+
129
+ .. code-block :: python
130
+
131
+ @pytest.fixture (scope = ' function' )
132
+ async def async_gen_fixture ():
133
+ yield await asyncio.sleep(0.1 )
134
+
135
+ @pytest.fixture (scope = ' function' )
136
+ async def async_fixture ():
137
+ return await asyncio.sleep(0.1 )
138
+
139
+ They behave just like a common fixtures, except that they **must ** be function-scoped.
140
+ That ensures that they a run in the same event loop as test function.
141
+
125
142
Markers
126
143
-------
127
144
@@ -172,6 +189,7 @@ Changelog
172
189
- Using ``forbid_global_loop `` now allows tests to use ``asyncio ``
173
190
subprocesses.
174
191
`#36 <https://github.com/pytest-dev/pytest-asyncio/issues/36 >`_
192
+ - support for async and async gen fixtures
175
193
176
194
0.5.0 (2016-09-07)
177
195
~~~~~~~~~~~~~~~~~~
You can’t perform that action at this time.
0 commit comments