File tree 3 files changed +30
-1
lines changed
3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 2
2
Changelog
3
3
=========
4
4
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
+
5
10
0.23.1 (2023-12-03)
6
11
===================
7
12
- 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(
609
609
# collected Python class, where it will be picked up by pytest.Class.collect()
610
610
# or pytest.Module.collect(), respectively
611
611
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
613
617
except (OutcomeException , Collector .CollectError ):
614
618
# Accessing Module.obj triggers a module import executing module-level
615
619
# 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():
17
17
)
18
18
result = pytester .runpytest ("--asyncio-mode=strict" , "--doctest-modules" )
19
19
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