@@ -158,23 +158,24 @@ def pytest_pyfunc_call(pyfuncitem):
158
158
"""
159
159
if "asyncio" in pyfuncitem .keywords :
160
160
if getattr (pyfuncitem .obj , "is_hypothesis_test" , False ):
161
- hypothesis_inner_test = getattr (
162
- pyfuncitem .obj .hypothesis .inner_test ,
163
- "original_test_function" ,
164
- pyfuncitem .obj .hypothesis .inner_test ,
165
- )
166
- synchronous_test_function = wrap_in_sync (
167
- hypothesis_inner_test ,
168
- _loop = pyfuncitem .funcargs ["event_loop" ],
169
- )
170
- pyfuncitem .obj .hypothesis .inner_test = synchronous_test_function
161
+ _wrap_hypothesis_test (pyfuncitem )
171
162
else :
172
163
pyfuncitem .obj = wrap_in_sync (
173
164
pyfuncitem .obj , _loop = pyfuncitem .funcargs ["event_loop" ]
174
165
)
175
166
yield
176
167
177
168
169
+ def _wrap_hypothesis_test (pyfuncitem ):
170
+ inner_test = pyfuncitem .obj .hypothesis .inner_test
171
+ original_test = getattr (inner_test , "original_test_function" , inner_test )
172
+ synchronous_test_function = wrap_in_sync (
173
+ original_test ,
174
+ _loop = pyfuncitem .funcargs ["event_loop" ],
175
+ )
176
+ pyfuncitem .obj .hypothesis .inner_test = synchronous_test_function
177
+
178
+
178
179
def wrap_in_sync (func , _loop ):
179
180
"""Return a sync wrapper around an async function executing it in the
180
181
current event loop."""
0 commit comments