Skip to content

Commit b274d22

Browse files
committed
Add async_yield as an alias for inlineCallbacks
For symmetry with the new async_await
1 parent aaff1ad commit b274d22

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ undesirably detected by ``pytest`` as an unknown hook. One alternative
5050
is to ``import pytest_twisted as pt``.
5151

5252

53-
inlineCallbacks
54-
=================
53+
inlineCallbacks (async_yield)
54+
=============================
5555
Using ``twisted.internet.defer.inlineCallbacks`` as a decorator for test
5656
functions, which take funcargs, does not work. Please use
5757
``pytest_twisted.inlineCallbacks`` instead::
@@ -62,6 +62,9 @@ functions, which take funcargs, does not work. Please use
6262
assert res == []
6363

6464

65+
For symmetry with ``async_await`` below, ``pytest_twisted.inlineCallbacks``
66+
is also available as ``pytest_twisted.async_yield``.
67+
6568
async_await
6669
=================
6770
Using ``twisted.internet.defer.ensureDeferred`` as a decorator for test

pytest_twisted.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def inlineCallbacks(fun, *args, **kw):
7373
return defer.inlineCallbacks(fun)(*args, **kw)
7474

7575

76+
async_yield = inlineCallbacks
77+
78+
7679
@decorator.decorator
7780
def async_await(fun, *args, **kw):
7881
return defer.ensureDeferred(fun(*args, **kw))

testing/test_basic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def cmd_opts(request):
5252
return ("--reactor={}".format(reactor),)
5353

5454

55+
def test_async_yield_is_inlineCallbacks()
56+
assert pytest_twisted.async_yield is pytest_twisted.inlineCallbacks
57+
58+
5559
def test_fail_later(testdir, cmd_opts):
5660
test_file = """
5761
from twisted.internet import reactor, defer

0 commit comments

Comments
 (0)