-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] Fixes a bug that caused internal pytest errors during test coll…
…ection with doctests. Pytest-asyncio attaches an event loop of a particular scope to each collector during pytest_collectstart. The implementation did not account for the fact that collectors may have specialized subclasses, such as DoctestModule. This caused a KeyError during a dictionary access, leading to an internal pytest error in the collection phase. This patch changes the implementation of pytest_collectstart to account for subclasses of collectors. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
- Loading branch information
Showing
2 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from textwrap import dedent | ||
|
||
from pytest import Pytester | ||
|
||
|
||
def test_plugin_does_not_interfere_with_doctest_collection(pytester: Pytester): | ||
pytester.makepyfile( | ||
dedent( | ||
'''\ | ||
def any_function(): | ||
""" | ||
>>> 42 | ||
42 | ||
""" | ||
''' | ||
), | ||
) | ||
result = pytester.runpytest("--asyncio-mode=strict", "--doctest-modules") | ||
result.assert_outcomes(passed=1) |