@@ -14,6 +14,14 @@ class WrongReactorAlreadyInstalledError(Exception):
14
14
pass
15
15
16
16
17
+ class UnrecognizedCoroutineMarkError (Exception ):
18
+ @classmethod
19
+ def from_mark (cls , mark ):
20
+ return cls (
21
+ 'Coroutine wrapper mark not recognized: {}' .format (repr (mark )),
22
+ )
23
+
24
+
17
25
class _config :
18
26
external_reactor = False
19
27
@@ -128,18 +136,26 @@ def _pytest_pyfunc_call(pyfuncitem):
128
136
if hasattr (pyfuncitem , "_fixtureinfo" ):
129
137
testargs = {}
130
138
for arg in pyfuncitem ._fixtureinfo .argnames :
131
- something = funcargs [arg ]
132
- if isinstance (something , _CoroutineWrapper ):
133
- if something .mark == 'async_fixture' :
134
- something = yield defer .ensureDeferred (
135
- something .coroutine
139
+ if isinstance (funcargs [arg ], _CoroutineWrapper ):
140
+ wrapper = funcargs [arg ]
141
+
142
+ if wrapper .mark == 'async_fixture' :
143
+ arg_value = yield defer .ensureDeferred (
144
+ wrapper .coroutine
145
+ )
146
+ elif wrapper .mark == 'async_yield_fixture' :
147
+ async_generators .append ((arg , wrapper ))
148
+ arg_value = yield defer .ensureDeferred (
149
+ wrapper .coroutine .__anext__ (),
136
150
)
137
- elif something .mark == 'async_yield_fixture' :
138
- async_generators .append ((arg , something ))
139
- something = yield defer .ensureDeferred (
140
- something .coroutine .__anext__ (),
151
+ else :
152
+ raise UnrecognizedCoroutineMarkError .from_mark (
153
+ wrapper .mark ,
141
154
)
142
- testargs [arg ] = something
155
+ else :
156
+ arg_value = funcargs [arg ]
157
+
158
+ testargs [arg ] = arg_value
143
159
else :
144
160
testargs = funcargs
145
161
result = yield testfunction (** testargs )
0 commit comments