diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 91983dd..8bbb8b9 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -70,6 +70,9 @@ jobs: - os: ubuntu-latest python-version: '3.13' toxenv: py313-test-pytestdev-numpydev + - os: ubuntu-latest + python-version: '3.13' + toxenv: py313-test-pytest83-pytestasyncio steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 diff --git a/CHANGES.rst b/CHANGES.rst index 8fe4a45..095e28f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,8 @@ 1.4.0 (unreleased) ================== +- Fixing compatibility with pytest-asyncio. [#278] + - Versions of Python <3.9 are no longer supported. [#274] 1.3.0 (2024-11-25) diff --git a/pytest_doctestplus/plugin.py b/pytest_doctestplus/plugin.py index 5290dd9..3f8e6da 100644 --- a/pytest_doctestplus/plugin.py +++ b/pytest_doctestplus/plugin.py @@ -342,6 +342,7 @@ def collect(self): test.name, self, runner, test) class DocTestTextfilePlus(pytest.Module): + obj = None def collect(self): if PYTEST_GE_7_0: diff --git a/tests/test_doctestplus.py b/tests/test_doctestplus.py index fb0ac37..6b54786 100644 --- a/tests/test_doctestplus.py +++ b/tests/test_doctestplus.py @@ -11,6 +11,13 @@ import doctest from pytest_doctestplus.output_checker import OutputChecker, FLOAT_CMP +try: + import pytest_asyncio # noqa: F401 + has_pytest_asyncio = True +except ImportError: + has_pytest_asyncio = False + + pytest_plugins = ['pytester'] @@ -1123,6 +1130,9 @@ class MyClass: assert ("something()\nUNEXPECTED EXCEPTION: NameError" in report.longreprtext) is cont_on_fail +@pytest.mark.xfail( + has_pytest_asyncio, + reason='pytest_asyncio monkey-patches .collect()') def test_main(testdir): pkg = testdir.mkdir('pkg') code = dedent( diff --git a/tox.ini b/tox.ini index eb158a0..d81ccfe 100644 --- a/tox.ini +++ b/tox.ini @@ -32,6 +32,7 @@ deps = pytest83: pytest==8.3.* pytestdev: git+https://github.com/pytest-dev/pytest#egg=pytest numpydev: numpy>=0.0.dev0 + pytestasyncio: pytest-asyncio extras = test