mirror of
https://github.com/python/cpython.git
synced 2025-10-03 13:45:29 +00:00
gh-128595: Fix test__colorize
unexpected keyword argument 'file' on buildbots (#129070)
This commit is contained in:
parent
e65a1eb93a
commit
417f7a9ef7
1 changed files with 5 additions and 1 deletions
|
@ -9,7 +9,7 @@ ORIGINAL_CAN_COLORIZE = _colorize.can_colorize
|
|||
|
||||
|
||||
def setUpModule():
|
||||
_colorize.can_colorize = lambda: False
|
||||
_colorize.can_colorize = lambda *args, **kwargs: False
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
|
@ -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),
|
||||
|
@ -29,6 +30,8 @@ class TestColorizeFunction(unittest.TestCase):
|
|||
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'}):
|
||||
|
@ -61,6 +64,7 @@ class TestColorizeFunction(unittest.TestCase):
|
|||
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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue