Skip to content

test_doctest.test_look_in_unwrapped does not test anything #118121

Closed
@sobolevn

Description

@sobolevn

Bug report

Here's a test that ensures that Wrapper on top of it handles __doc__ correcty:

class Wrapper:
def __init__(self, func):
self.func = func
functools.update_wrapper(self, func)
def __call__(self, *args, **kwargs):
self.func(*args, **kwargs)
@Wrapper
def test_look_in_unwrapped():
"""
Docstrings in wrapped functions must be detected as well.
>>> 'one other test'
'one other test'
"""

The problem is that it does not check that tests are actually executed.

If you remove this doctest from it, this will be the result:

» ./python.exe -m test test_doctest
Using random seed: 2548604185
0:00:00 load avg: 1.71 Run 1 test sequentially
0:00:00 load avg: 1.71 [1/1] test_doctest

== Tests result: SUCCESS ==

1 test OK.

Total duration: 955 ms
Total tests: run=67
Total test files: run=1/1
Result: SUCCESS

So, it does not test anything. And it will continue to pass if Wrapper won't handle __doc__ correctly at some point.

I have a PR ready.

Linked PRs

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions