Skip to content

test_pydoc.test_pydoc fails with a -R 3:3 option #120590

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
Eclips4 opened this issue Jun 16, 2024 · 2 comments
Closed

test_pydoc.test_pydoc fails with a -R 3:3 option #120590

Eclips4 opened this issue Jun 16, 2024 · 2 comments
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@Eclips4
Copy link
Member

Eclips4 commented Jun 16, 2024

Bug report

Bug description:

./python.exe -m test -R 3:3 test_pydoc.test_pydoc

The output of the tests is in the attached file.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

output.txt

Linked PRs

@Eclips4 Eclips4 added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir labels Jun 16, 2024
@Eclips4
Copy link
Member Author

Eclips4 commented Jun 16, 2024

cc @serhiy-storchaka

@serhiy-storchaka serhiy-storchaka self-assigned this Jun 16, 2024
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jun 17, 2024
Mocking only works if sys.modules['pydoc'] and pydoc are the same,
but some pydoc functions reload the module and change sys.modules.
Ensure that sys.modules['pydoc'] is always restored after the corresponding
tests.
@serhiy-storchaka
Copy link
Member

It fails because sys.modules['pydoc'] and pydoc (imported at the top of test_pydoc) are not the same. Some pydoc functions reload the module and change sys.modules. The first pass is successful because tests with such side effect are run after tests that use unittest.mock.patch, but the second pass fails.

There are other tests that use unittest.mock.patch, they do not fail, but the second pass do not test what it was intended.

The PR restores sys.modules['pydoc'] after it was modified and adds a check after every test to ensure that it was restored (because we may add new tests in future).

serhiy-storchaka added a commit that referenced this issue Jun 18, 2024
Mocking only works if sys.modules['pydoc'] and pydoc are the same,
but some pydoc functions reload the module and change sys.modules.
Ensure that sys.modules['pydoc'] is always restored after the corresponding
tests.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 18, 2024
…-120615)

Mocking only works if sys.modules['pydoc'] and pydoc are the same,
but some pydoc functions reload the module and change sys.modules.
Ensure that sys.modules['pydoc'] is always restored after the corresponding
tests.
(cherry picked from commit 2cf4738)

Co-authored-by: Serhiy Storchaka <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 18, 2024
…-120615)

Mocking only works if sys.modules['pydoc'] and pydoc are the same,
but some pydoc functions reload the module and change sys.modules.
Ensure that sys.modules['pydoc'] is always restored after the corresponding
tests.
(cherry picked from commit 2cf4738)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this issue Jun 18, 2024
…) (GH-120670)

Mocking only works if sys.modules['pydoc'] and pydoc are the same,
but some pydoc functions reload the module and change sys.modules.
Ensure that sys.modules['pydoc'] is always restored after the corresponding
tests.
(cherry picked from commit 2cf4738)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this issue Jun 18, 2024
…) (GH-120669)

Mocking only works if sys.modules['pydoc'] and pydoc are the same,
but some pydoc functions reload the module and change sys.modules.
Ensure that sys.modules['pydoc'] is always restored after the corresponding
tests.
(cherry picked from commit 2cf4738)

Co-authored-by: Serhiy Storchaka <[email protected]>
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
…-120615)

Mocking only works if sys.modules['pydoc'] and pydoc are the same,
but some pydoc functions reload the module and change sys.modules.
Ensure that sys.modules['pydoc'] is always restored after the corresponding
tests.
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
…-120615)

Mocking only works if sys.modules['pydoc'] and pydoc are the same,
but some pydoc functions reload the module and change sys.modules.
Ensure that sys.modules['pydoc'] is always restored after the corresponding
tests.
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…-120615)

Mocking only works if sys.modules['pydoc'] and pydoc are the same,
but some pydoc functions reload the module and change sys.modules.
Ensure that sys.modules['pydoc'] is always restored after the corresponding
tests.
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

2 participants