Skip to content

Commit 81fe4fd

Browse files
authored
Merge pull request #278 from geigerzaehler/pytest-asyncio-compat
Make compatible with pytest-asyncio
2 parents 9a4069f + 8c61c74 commit 81fe4fd

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

.github/workflows/python-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ jobs:
7070
- os: ubuntu-latest
7171
python-version: '3.13'
7272
toxenv: py313-test-pytestdev-numpydev
73+
- os: ubuntu-latest
74+
python-version: '3.13'
75+
toxenv: py313-test-pytest83-pytestasyncio
7376

7477
steps:
7578
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
1.4.0 (unreleased)
22
==================
33

4+
- Fixing compatibility with pytest-asyncio. [#278]
5+
46
- Versions of Python <3.9 are no longer supported. [#274]
57

68
1.3.0 (2024-11-25)

pytest_doctestplus/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ def collect(self):
342342
test.name, self, runner, test)
343343

344344
class DocTestTextfilePlus(pytest.Module):
345+
obj = None
345346

346347
def collect(self):
347348
if PYTEST_GE_7_0:

tests/test_doctestplus.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
import doctest
1212
from pytest_doctestplus.output_checker import OutputChecker, FLOAT_CMP
1313

14+
try:
15+
import pytest_asyncio # noqa: F401
16+
has_pytest_asyncio = True
17+
except ImportError:
18+
has_pytest_asyncio = False
19+
20+
1421

1522
pytest_plugins = ['pytester']
1623

@@ -1123,6 +1130,9 @@ class MyClass:
11231130
assert ("something()\nUNEXPECTED EXCEPTION: NameError" in report.longreprtext) is cont_on_fail
11241131

11251132

1133+
@pytest.mark.xfail(
1134+
has_pytest_asyncio,
1135+
reason='pytest_asyncio monkey-patches .collect()')
11261136
def test_main(testdir):
11271137
pkg = testdir.mkdir('pkg')
11281138
code = dedent(

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ deps =
3232
pytest83: pytest==8.3.*
3333
pytestdev: git+https://github.com/pytest-dev/pytest#egg=pytest
3434
numpydev: numpy>=0.0.dev0
35+
pytestasyncio: pytest-asyncio
3536

3637
extras =
3738
test

0 commit comments

Comments
 (0)