Only rely on _find on Python 3.9 and earlier.

This commit is contained in:
Jason R. Coombs 2024-06-06 11:13:32 -04:00
parent 9df3357ad6
commit 967144fd94
No known key found for this signature in database
GPG Key ID: 708E6CB181B4C47E
1 changed files with 17 additions and 16 deletions

View File

@ -505,12 +505,6 @@ class DoctestModule(Module):
import doctest
class MockAwareDocTestFinder(doctest.DocTestFinder):
"""A hackish doctest finder that overrides stdlib internals to fix a stdlib bug.
https://github.com/pytest-dev/pytest/issues/3456
https://bugs.python.org/issue25532
"""
if sys.version_info < (3, 11):
def _find_lineno(self, obj, source_lines):
@ -533,16 +527,23 @@ class DoctestModule(Module):
source_lines,
)
def _find(
self, tests, obj, name, module, source_lines, globs, seen
) -> None:
if _is_mocked(obj):
return
with _patch_unwrap_mock_aware():
# Type ignored because this is a private function.
super()._find( # type:ignore[misc]
tests, obj, name, module, source_lines, globs, seen
)
if sys.version_info < (3, 10):
def _find(
self, tests, obj, name, module, source_lines, globs, seen
) -> None:
"""Override _find to work around issue in stdlib.
https://github.com/pytest-dev/pytest/issues/3456
https://github.com/python/cpython/issues/69718
"""
if _is_mocked(obj):
return
with _patch_unwrap_mock_aware():
# Type ignored because this is a private function.
super()._find( # type:ignore[misc]
tests, obj, name, module, source_lines, globs, seen
)
if sys.version_info < (3, 13):