Skip to content

gh-135237: fix setUp/tearDown of _colorize.can_colorize in test_argparse #135238

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tpburns
Copy link
Contributor

@tpburns tpburns commented Jun 7, 2025

See test_regrtest TestColorized and test_pdb PdbTestColorize for similar tests with safe setups.

with unittest.mock.patch(
"_colorize.can_colorize", return_value=True
):
result = results.get_state(fail_env_changed=False)

cpython/Lib/test/test_pdb.py

Lines 4694 to 4701 in 24069fb

def setUp(self):
self._original_can_colorize = _colorize.can_colorize
# Force colorize to be enabled because we are sending data
# to a StringIO
_colorize.can_colorize = lambda *args, **kwargs: True
def tearDown(self):
_colorize.can_colorize = self._original_can_colorize

@picnixz picnixz changed the title gh-135237 Add tearDown for _colorize.can_colorize modification in test_argparse gh-135237: Add tearDown for _colorize.can_colorize modification in test_argparse Jun 7, 2025
@sobolevn sobolevn added the needs backport to 3.14 bugs and security fixes label Jun 7, 2025
@sobolevn sobolevn removed the needs backport to 3.14 bugs and security fixes label Jun 7, 2025
@picnixz picnixz changed the title gh-135237: Add tearDown for _colorize.can_colorize modification in test_argparse gh-135237: fix setUp/tearDown of _colorize.can_colorize in test_argparse Jun 7, 2025
@ZeroIntensity ZeroIntensity added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 7, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit e27c90b 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F135238%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting merge skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants