File tree 1 file changed +9
-5
lines changed 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -42,15 +42,19 @@ def pytest_addoption(parser):
42
42
parser .addoption ("--with-e2e" , action = "store_true" , help = "Include end-to-end tests." )
43
43
44
44
45
+ # Make all tests in this directory and below asyncio-compatible by default.
46
+ # Due to how pytest-async checks for these markers, they should be added as early as possible.
47
+ @pytest .hookimpl (hookwrapper = True )
48
+ def pytest_pycollect_makeitem (collector , name , obj ):
49
+ if collector .funcnamefilter (name ) and asyncio .iscoroutinefunction (obj ):
50
+ pytest .mark .asyncio (obj )
51
+ yield
52
+
53
+
45
54
# This logic is not applied if pytest is started explicitly on ./examples/.
46
55
# In that case, regular pytest behaviour applies -- this is intended.
47
56
def pytest_collection_modifyitems (config , items ):
48
57
49
- # Make all tests in this directory and below asyncio-compatible by default.
50
- for item in items :
51
- if asyncio .iscoroutinefunction (item .function ):
52
- item .add_marker ('asyncio' )
53
-
54
58
# Put all e2e tests to the end, as they are assumed to be slow.
55
59
def _is_e2e (item ):
56
60
path = item .location [0 ]
You can’t perform that action at this time.
0 commit comments