-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
gh-128595: Add test class helper to force no terminal colour #128687
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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.
@@ -17,6 +17,7 @@ | |||
import types | |||
import unittest | |||
import warnings | |||
from collections.abc import Callable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can go now :)
from collections.abc import Callable |
@@ -17,6 +17,7 @@ | |||
import types | |||
import unittest | |||
import warnings | |||
from collections.abc import Callable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import is unused.
Split out from #128498, as requested at #128498 (comment).