File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -111,10 +111,25 @@ async/await fixtures
111111pytest fixture semantics of setup, value, and teardown. At present only
112112function scope is supported.
113113
114+ Note: You must *call * ``pytest_twisted.async_fixture() `` and
115+ ``pytest_twisted.async_yield_fixture() ``.
116+ This requirement may be removed in a future release.
117+
114118.. code-block :: python
115119
116- @pytest_twisted.async_fixture
120+ # No yield (coroutine function)
121+ # -> use pytest_twisted.async_fixture()
122+ @pytest_twisted.async_fixture ()
117123 async def foo ():
124+ d = defer.Deferred()
125+ reactor.callLater(0.01 , d.callback, 42 )
126+ value = await d
127+ return value
128+
129+ # With yield (asynchronous generator)
130+ # -> use pytest_twisted.async_yield_fixture()
131+ @pytest_twisted.async_yield_fixture ()
132+ async def foo_with_teardown ():
118133 d1, d2 = defer.Deferred(), defer.Deferred()
119134 reactor.callLater(0.01 , d1.callback, 42 )
120135 reactor.callLater(0.02 , d2.callback, 37 )
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ class AsyncFixtureUnsupportedScopeError(Exception):
3535 @classmethod
3636 def from_scope (cls , scope ):
3737 return cls (
38- 'Unsupported scope used for async fixture: {} ' .format (scope )
38+ 'Unsupported scope {0!r} used for async fixture' .format (scope )
3939 )
4040
4141
You can’t perform that action at this time.
0 commit comments