Skip to content

Commit 91346e6

Browse files
committed
Fix compatibility with pytest 3.8.1
Apparently for a test *method*, item.obj and item.function are different: item.obj is the bound method, and item.function is the underlying unbound method. At least in pytest 3.8.1. We want to wrap the bound method, not the unbound method, so we should wrap item.obj, not item.function.
1 parent 6706f8b commit 91346e6

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

newsfragments/64.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The pytest 3.8.1 release broke pytest-trio's handling of trio tests
2+
defined as class methods. We fixed it again.

pytest_trio/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ async def run(self, test_ctx, contextvars_ctx):
292292

293293

294294
def _trio_test_runner_factory(item, testfunc=None):
295-
testfunc = testfunc or item.function
295+
testfunc = testfunc or item.obj
296296

297297
if getattr(testfunc, '_trio_test_runner_wrapped', False):
298298
# We have already wrapped this, perhaps because we combined Hypothesis

0 commit comments

Comments
 (0)