Skip to content

Commit 417f7a9

Browse files
authored
gh-128595: Fix test__colorize unexpected keyword argument 'file' on buildbots (#129070)
1 parent e65a1eb commit 417f7a9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/test/test__colorize.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
def setUpModule():
12-
_colorize.can_colorize = lambda: False
12+
_colorize.can_colorize = lambda *args, **kwargs: False
1313

1414

1515
def tearDownModule():
@@ -21,6 +21,7 @@ class TestColorizeFunction(unittest.TestCase):
2121
def test_colorized_detection_checks_for_environment_variables(self):
2222
flags = unittest.mock.MagicMock(ignore_environment=False)
2323
with (unittest.mock.patch("os.isatty") as isatty_mock,
24+
unittest.mock.patch("sys.stdout") as stdout_mock,
2425
unittest.mock.patch("sys.stderr") as stderr_mock,
2526
unittest.mock.patch("sys.flags", flags),
2627
unittest.mock.patch("_colorize.can_colorize", ORIGINAL_CAN_COLORIZE),
@@ -29,6 +30,8 @@ def test_colorized_detection_checks_for_environment_variables(self):
2930
contextlib.nullcontext()) as vt_mock):
3031

3132
isatty_mock.return_value = True
33+
stdout_mock.fileno.return_value = 1
34+
stdout_mock.isatty.return_value = True
3235
stderr_mock.fileno.return_value = 2
3336
stderr_mock.isatty.return_value = True
3437
with unittest.mock.patch("os.environ", {'TERM': 'dumb'}):
@@ -61,6 +64,7 @@ def test_colorized_detection_checks_for_environment_variables(self):
6164
self.assertEqual(_colorize.can_colorize(), True)
6265

6366
isatty_mock.return_value = False
67+
stdout_mock.isatty.return_value = False
6468
stderr_mock.isatty.return_value = False
6569
self.assertEqual(_colorize.can_colorize(), False)
6670

0 commit comments

Comments
 (0)