8000 `test_doctest.test_look_in_unwrapped` does not test anything · Issue #118121 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

test_doctest.test_look_in_unwrapped does not test anything #118121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sobolevn opened this issue Apr 20, 2024 · 0 comments
Closed

test_doctest.test_look_in_unwrapped does not test anything #118121

sobolevn opened this issue Apr 20, 2024 · 0 comments
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member
sobolevn commented Apr 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant
0