Skip to content

Commit 0d56b40

Browse files
authored
Merge branch 'master' into release-0.5.0
2 parents 3197b91 + 77f54c1 commit 0d56b40

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

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/_tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
# Temporary hack while waiting for an answer here:
2+
# https://github.com/pytest-dev/pytest/issues/4039
3+
import pytest
4+
import warnings
5+
warnings.filterwarnings(
6+
"default",
7+
category=pytest.RemovedInPytest4Warning,
8+
message=".*non-top-level conftest.*",
9+
)
10+
111
pytest_plugins = ["pytester"]

pytest_trio/_tests/test_trio_asyncio.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
pytestmark = pytest.mark.skip(reason="trio-asyncio not available")
1010

1111

12-
async def use_run_asyncio():
13-
await trio_asyncio.run_asyncio(asyncio.sleep, 0)
12+
async def use_asyncio():
13+
await trio_asyncio.aio_as_trio(asyncio.sleep)(0)
1414

1515

1616
@pytest.fixture()
@@ -23,29 +23,29 @@ async def asyncio_loop():
2323
@pytest.fixture()
2424
@async_generator
2525
async def asyncio_fixture_with_fixtured_loop(asyncio_loop):
26-
await use_run_asyncio()
26+
await use_asyncio()
2727
await yield_()
2828

2929

3030
@pytest.fixture()
3131
@async_generator
3232
async def asyncio_fixture_own_loop():
3333
async with trio_asyncio.open_loop():
34-
await use_run_asyncio()
34+
await use_asyncio()
3535
await yield_()
3636

3737

3838
@pytest.mark.trio
3939
async def test_no_fixture():
4040
async with trio_asyncio.open_loop():
41-
await use_run_asyncio()
41+
await use_asyncio()
4242

4343

4444
@pytest.mark.trio
4545
async def test_half_fixtured_asyncpg_conn(asyncio_fixture_own_loop):
46-
await use_run_asyncio()
46+
await use_asyncio()
4747

4848

4949
@pytest.mark.trio
5050
async def test_fixtured_asyncpg_conn(asyncio_fixture_with_fixtured_loop):
51-
await use_run_asyncio()
51+
await use_asyncio()

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)