From 7183d07f75ed4da3b29148c03c0b1a356145a838 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Tue, 18 Jun 2024 10:32:59 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20Clarify=20patch=20condition=20fo?= =?UTF-8?q?r=20doctest=20finder=20hack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was a regression caused by #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 #12430. Co-authored-by: Florian Bruhin --- src/_pytest/doctest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 23ad7a7a9..e61694d55 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -505,7 +505,13 @@ class DoctestModule(Module): 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