File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 22Changelog
33=========
44
5+ 0.23.2 (2023-12-04)
6+ ===================
7+ - Fixes a bug that caused an internal pytest error when collecting .txt files `#703 <https://github.com/pytest-dev/pytest-asyncio/issues/703 >`_
8+
9+
5100.23.1 (2023-12-03)
611===================
712- Fixes a bug that caused an internal pytest error when using module-level skips `#701 <https://github.com/pytest-dev/pytest-asyncio/issues/701 >`_
Original file line number Diff line number Diff line change @@ -609,7 +609,11 @@ def scoped_event_loop(
609609 # collected Python class, where it will be picked up by pytest.Class.collect()
610610 # or pytest.Module.collect(), respectively
611611 try :
612- collector .obj .__pytest_asyncio_scoped_event_loop = scoped_event_loop
612+ pyobject = collector .obj
613+ # If the collected module is a DoctestTextfile, collector.obj is None
614+ if pyobject is None :
615+ return
616+ pyobject .__pytest_asyncio_scoped_event_loop = scoped_event_loop
613617 except (OutcomeException , Collector .CollectError ):
614618 # Accessing Module.obj triggers a module import executing module-level
615619 # statements. A module-level pytest.skip statement raises the "Skipped"
Original file line number Diff line number Diff line change @@ -17,3 +17,23 @@ def any_function():
1717 )
1818 result = pytester .runpytest ("--asyncio-mode=strict" , "--doctest-modules" )
1919 result .assert_outcomes (passed = 1 )
20+
21+
22+ def test_plugin_does_not_interfere_with_doctest_textfile_collection (pytester : Pytester ):
23+ pytester .makefile (".txt" , "" ) # collected as DoctestTextfile
24+ pytester .makepyfile (
25+ __init__ = "" ,
26+ test_python_file = dedent (
27+ """\
28+ import pytest
29+
30+ pytest_plugins = "pytest_asyncio"
31+
32+ @pytest.mark.asyncio
33+ async def test_anything():
34+ pass
35+ """
36+ ),
37+ )
38+ result = pytester .runpytest ("--asyncio-mode=strict" )
39+ result .assert_outcomes (passed = 1 )
You can’t perform that action at this time.
0 commit comments