gh-117692: Fix `AttributeError` in `DocTestFinder` on wrapped `builti… · python/cpython@4bb7d12 · GitHub
Skip to content

Commit 4bb7d12

Browse files
gh-117692: Fix AttributeError in DocTestFinder on wrapped builtin_or_method (#117699)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent f90ff03 commit 4bb7d12

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
@@ -2553,6 +2553,20 @@ def test_look_in_unwrapped():
25532553
'one other test'
25542554
"""
25552555

2556+
@doctest_skip_if(support.check_impl_detail(cpython=False))
2557+
def test_wrapped_c_func():
2558+
"""
2559+
# https://github.com/python/cpython/issues/117692
2560+
>>> import binascii
2561+
>>> from test.test_doctest.decorator_mod import decorator
2562+
2563+
>>> c_func_wrapped = decorator(binascii.b2a_hex)
2564+
>>> tests = doctest.DocTestFinder(exclude_empty=False).find(c_func_wrapped)
2565+
>>> for test in tests:
2566+
... print(test.lineno, test.name)
2567+
None b2a_hex
2568+
"""
2569+
25562570
def test_unittest_reportflags():
25572571
"""Default unittest reporting flags can be set to control reporting
25582572
Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)