[3.12] gh-117692: Fix `AttributeError` in `DocTestFinder` on wrapped … · python/cpython@653ed76 · GitHub
Skip to content

Commit 653ed76

Browse files
miss-islingtonsobolevnAlexWaygood
authored
[3.12] gh-117692: Fix AttributeError in DocTestFinder on wrapped builtin_or_method (GH-117699) (#117708)
* gh-117692: Fix `AttributeError` in `DocTestFinder` on wrapped `builtin_or_method` (GH-117699) (cherry picked from commit 4bb7d12) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent 559b25f commit 653ed76

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

Lib/doctest.py

Lines changed: 8 additions & 1 deletion

Lib/test/test_doctest/test_doctest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,6 +2496,20 @@ def test_look_in_unwrapped():
24962496
'one other test'
24972497
"""
24982498

2499+
if support.check_impl_detail(cpython=True):
2500+
def test_wrapped_c_func():
2501+
"""
2502+
# https://github.com/python/cpython/issues/117692
2503+
>>> import binascii
2504+
>>> from test.test_doctest.decorator_mod import decorator
2505+
2506+
>>> c_func_wrapped = decorator(binascii.b2a_hex)
2507+
>>> tests = doctest.DocTestFinder(exclude_empty=False).find(c_func_wrapped)
2508+
>>> for test in tests:
2509+
... print(test.lineno, test.name)
2510+
None b2a_hex
2511+
"""
2512+
24992513
def test_unittest_reportflags():
25002514
"""Default unittest reporting flags can be set to control reporting
25012515
Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)