Skip to content

Commit 94fb2a3

Browse files
committed
document difference between @inlineCallbacks @ensureDeferred approach
1 parent c505e50 commit 94fb2a3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pytest_twisted.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ def inlineCallbacks(f):
123123
"""
124124
Mark as inline callbacks test for pytest-twisted processing and apply
125125
@inlineCallbacks.
126+
127+
Unlike @ensureDeferred, @inlineCallbacks can be applied here because it
128+
does not call nor schedule the test function. Further, @inlineCallbacks
129+
must be applied here otherwise pytest identifies the test as a 'yield test'
130+
for which they dropped support in 4.0 and now they skip.
126131
"""
127132
decorated = decorator_apply(defer.inlineCallbacks, f)
128133
_set_mark(o=decorated, mark='inline_callbacks_test')
@@ -131,7 +136,12 @@ def inlineCallbacks(f):
131136

132137

133138
def ensureDeferred(f):
134-
"""Mark as async test for pytest-twisted processing."""
139+
"""
140+
Mark as async test for pytest-twisted processing.
141+
142+
Unlike @inlineCallbacks, @ensureDeferred must not be applied here since it
143+
would call and schedule the test function.
144+
"""
135145
_set_mark(o=f, mark='async_test')
136146

137147
return f

0 commit comments

Comments
 (0)