Skip to content

Commit

Permalink
πŸš‘ Clarify patch condition for doctest finder hack (pytest-dev#12471)
Browse files Browse the repository at this point in the history
There was a regression caused by pytest-dev#12431 that excluded the patch on
broken CPython patch version ranges 3.11.0–3.11.8 and 3.12.0–3.12.2.

This change fixes that by adjusting the patching conditional clause
to include said versions.

Closes pytest-dev#12430.

Co-authored-by: Florian Bruhin <me@the-compiler.org>
  • Loading branch information
webknjaz and The-Compiler authored Jun 18, 2024
1 parent fe4961a commit 49374ec
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/_pytest/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,13 @@ def collect(self) -> Iterable[DoctestItem]:
import doctest

class MockAwareDocTestFinder(doctest.DocTestFinder):
if sys.version_info < (3, 11):
py_ver_info_minor = sys.version_info[:2]
is_find_lineno_broken = (
py_ver_info_minor < (3, 11)
or (py_ver_info_minor == (3, 11) and sys.version_info.micro < 9)
or (py_ver_info_minor == (3, 12) and sys.version_info.micro < 3)
)
if is_find_lineno_broken:

def _find_lineno(self, obj, source_lines):
"""On older Pythons, doctest code does not take into account
Expand Down

0 comments on commit 49374ec

Please sign in to comment.