Uh oh!
There was an error while loading. Please reload this page.
gh-128595: Add test class helper to force no terminal colour - #128687
Conversation
serhiy-storchaka
left a comment
There was a problem hiding this comment.
- You can disable colorizing for the whole class in
setUpClass()instead ofsetUp(). - Would not it be simpler to implement the core functionality as a generator-based context manager? You can use
enterContext()orenterClassContext()with it. - You can use
test.support.os_helper.EnvironmentVarGuard()to restore the environment andtest.support.swap_attr()to restore_colorize.can_colorize.
You can also implement this as a mixin instead of patching a method (use a super() call in an overridden method). I do not say that it would be better, but it is just an alternative which you could have overlooked.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…ce_not_colorized_test_class
vstinner
left a comment
There was a problem hiding this comment.
Oh nice, the new code is more readable, I prefer context managers :-)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM. Much clearer now!
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, @hugovk, I could not cleanly backport this to |
hugovk
commented
Jan 13, 2025
Thanks for the reviews! |
…lour (pythonGH-128687) (cherry picked from commit afb9dc8) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
GH-128778 is a backport of this pull request to the 3.13 branch. |
Split out from #128498, as requested at #128498 (comment).