summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest
diff options
context:
space:
mode:
authorBrian Schubert <brianm.schubert@gmail.com>2024-02-14 15:01:27 (GMT)
committerGitHub <noreply@github.com>2024-02-14 15:01:27 (GMT)
commitbb791c7728e0508ad5df28a90b27e202d66a9cfa (patch)
tree07a5bb7cabca6eae8ad01abb1d17258b9ae8df3e /Lib/test/test_doctest
parent6755c4e0c8803a246e632835030c0b8837b3b676 (diff)
downloadcpython-bb791c7728e0508ad5df28a90b27e202d66a9cfa.zip
cpython-bb791c7728e0508ad5df28a90b27e202d66a9cfa.tar.gz
cpython-bb791c7728e0508ad5df28a90b27e202d66a9cfa.tar.bz2
gh-115392: Fix doctest reporting incorrect line numbers for decorated functions (#115440)
Diffstat (limited to 'Lib/test/test_doctest')
-rw-r--r--Lib/test/test_doctest/decorator_mod.py10
-rw-r--r--Lib/test/test_doctest/doctest_lineno.py9
-rw-r--r--Lib/test/test_doctest/test_doctest.py1
3 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_doctest/decorator_mod.py b/Lib/test/test_doctest/decorator_mod.py
new file mode 100644
index 0000000..9f10688
--- /dev/null
+++ b/Lib/test/test_doctest/decorator_mod.py
@@ -0,0 +1,10 @@
+# This module is used in `doctest_lineno.py`.
+import functools
+
+
+def decorator(f):
+ @functools.wraps(f)
+ def inner():
+ return f()
+
+ return inner
diff --git a/Lib/test/test_doctest/doctest_lineno.py b/Lib/test/test_doctest/doctest_lineno.py
index 677c569..0dbcd9a 100644
--- a/Lib/test/test_doctest/doctest_lineno.py
+++ b/Lib/test/test_doctest/doctest_lineno.py
@@ -67,3 +67,12 @@ class MethodWrapper:
# https://github.com/python/cpython/issues/99433
str_wrapper = object().__str__
+
+
+# https://github.com/python/cpython/issues/115392
+from test.test_doctest.decorator_mod import decorator
+
+@decorator
+@decorator
+def func_with_docstring_wrapped():
+ """Some unrelated info."""
diff --git a/Lib/test/test_doctest/test_doctest.py b/Lib/test/test_doctest/test_doctest.py
index 7015255..43be200 100644
--- a/Lib/test/test_doctest/test_doctest.py
+++ b/Lib/test/test_doctest/test_doctest.py
@@ -685,6 +685,7 @@ It used to be broken for quite some time until `bpo-28249`.
None test.test_doctest.doctest_lineno.MethodWrapper.method_without_docstring
61 test.test_doctest.doctest_lineno.MethodWrapper.property_with_doctest
4 test.test_doctest.doctest_lineno.func_with_docstring
+ 77 test.test_doctest.doctest_lineno.func_with_docstring_wrapped
12 test.test_doctest.doctest_lineno.func_with_doctest
None test.test_doctest.doctest_lineno.func_without_docstring