Skip to content

Restore decimal context after decimal doctests #120149

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

Conversation

serhiy-storchaka
Copy link
Member

The modified context caused tests failures in several other tests.

@serhiy-storchaka
Copy link
Member Author

See #117962 (comment) for details.

This is an extended variant of #120147 for main. Even if the decimal doctests do not break other tests in 3.13 and main, the context is still changed, and I believe that restoring it is the right thing.

The modified context caused tests failures in several other tests.
@serhiy-storchaka
Copy link
Member Author

The root of the problem is perhaps in #89392. Before this, all decimal tests were run in test_main, which restored the context at the end. Now tests are better integrated with unittest. The cleanup code was moved to tearDownModule(), and DocTestSuite is used to run doctests. But tearDownModule() is now run before running doctests (because they are marked as belonging to other module, not test_decimal), so the context is not restored after doctests.

I still does not know why this broke other tests only in 3.12. Perhaps it is related to the import system or to reloadability of the _decimal module.

@serhiy-storchaka serhiy-storchaka merged commit 2d7ff6e into python:main Jun 6, 2024
31 checks passed
@serhiy-storchaka serhiy-storchaka deleted the test-decimal-doctests-restore-context branch June 6, 2024 17:12
@serhiy-storchaka serhiy-storchaka added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Jun 6, 2024
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@bedevere-app
Copy link

bedevere-app bot commented Jun 6, 2024

GH-120167 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 6, 2024
@bedevere-app
Copy link

bedevere-app bot commented Jun 6, 2024

GH-120168 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Jun 6, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 6, 2024
The modified context caused tests failures in several other tests.
(cherry picked from commit 2d7ff6e)

Co-authored-by: Serhiy Storchaka <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 6, 2024
The modified context caused tests failures in several other tests.
(cherry picked from commit 2d7ff6e)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Jun 6, 2024
…-120168)

The modified context caused tests failures in several other tests.
(cherry picked from commit 2d7ff6e)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Jun 6, 2024
…-120167)

The modified context caused tests failures in several other tests.
(cherry picked from commit 2d7ff6e)

Co-authored-by: Serhiy Storchaka <[email protected]>
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
The modified context caused tests failures in several other tests.
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
The modified context caused tests failures in several other tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip issue skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant