Skip to content

gh-128595: Fix test__colorize unexpected keyword argument 'file' on buildbots #129070

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

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Lib/test/test__colorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def setUpModule():
_colorize.can_colorize = lambda: False
_colorize.can_colorize = lambda *args, **kwargs: False


def tearDownModule():
Expand All @@ -21,6 +21,7 @@ class TestColorizeFunction(unittest.TestCase):
def test_colorized_detection_checks_for_environment_variables(self):
flags = unittest.mock.MagicMock(ignore_environment=False)
with (unittest.mock.patch("os.isatty") as isatty_mock,
unittest.mock.patch("sys.stdout") as stdout_mock,
unittest.mock.patch("sys.stderr") as stderr_mock,
unittest.mock.patch("sys.flags", flags),
unittest.mock.patch("_colorize.can_colorize", ORIGINAL_CAN_COLORIZE),
Expand All @@ -29,6 +30,8 @@ def test_colorized_detection_checks_for_environment_variables(self):
contextlib.nullcontext()) as vt_mock):

isatty_mock.return_value = True
stdout_mock.fileno.return_value = 1
stdout_mock.isatty.return_value = True
stderr_mock.fileno.return_value = 2
stderr_mock.isatty.return_value = True
with unittest.mock.patch("os.environ", {'TERM': 'dumb'}):
Expand Down Expand Up @@ -61,6 +64,7 @@ def test_colorized_detection_checks_for_environment_variables(self):
self.assertEqual(_colorize.can_colorize(), True)

isatty_mock.return_value = False
stdout_mock.isatty.return_value = False
stderr_mock.isatty.return_value = False
self.assertEqual(_colorize.can_colorize(), False)

Expand Down
Loading