File tree 2 files changed +53
-0
lines changed
2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,9 @@ def pytest_pycollect_makeitem(
320
320
if not collector .funcnamefilter (name ):
321
321
return None
322
322
_preprocess_async_fixtures (collector .config , _HOLDER )
323
+ if isinstance (obj , staticmethod ):
324
+ # staticmethods need to be unwrapped.
325
+ obj = getattr (obj , "__func__" , False )
323
326
if (
324
327
_is_coroutine (obj )
325
328
or _is_hypothesis_test (obj )
Original file line number Diff line number Diff line change @@ -87,3 +87,53 @@ async def test_a(self, fixture_a):
87
87
)
88
88
result = testdir .runpytest ("--asyncio-mode=auto" )
89
89
result .assert_outcomes (passed = 1 )
90
+
91
+
92
+ def test_auto_mode_static_method (testdir ):
93
+ testdir .makepyfile (
94
+ dedent (
95
+ """\
96
+ import asyncio
97
+
98
+ pytest_plugins = 'pytest_asyncio'
99
+
100
+
101
+ class TestA:
102
+
103
+ @staticmethod
104
+ async def test_a():
105
+ await asyncio.sleep(0)
106
+ """
107
+ )
108
+ )
109
+ result = testdir .runpytest ("--asyncio-mode=auto" )
110
+ result .assert_outcomes (passed = 1 )
111
+
112
+
113
+ def test_auto_mode_static_method_fixture (testdir ):
114
+ testdir .makepyfile (
115
+ dedent (
116
+ """\
117
+ import asyncio
118
+ import pytest
119
+
120
+ pytest_plugins = 'pytest_asyncio'
121
+
122
+
123
+ class TestA:
124
+
125
+ @staticmethod
126
+ @pytest.fixture
127
+ async def fixture_a():
128
+ await asyncio.sleep(0)
129
+ return 1
130
+
131
+ @staticmethod
132
+ async def test_a(fixture_a):
133
+ await asyncio.sleep(0)
134
+ assert fixture_a == 1
135
+ """
136
+ )
137
+ )
138
+ result = testdir .runpytest ("--asyncio-mode=auto" )
139
+ result .assert_outcomes (passed = 1 )
You can’t perform that action at this time.
0 commit comments