|
5 | 5 | import mock |
6 | 6 | import pytest |
7 | 7 |
|
| 8 | +from pre_commit import envcontext |
8 | 9 | from pre_commit.color import format_color |
9 | 10 | from pre_commit.color import GREEN |
10 | 11 | from pre_commit.color import InvalidColorSetting |
@@ -38,13 +39,22 @@ def test_use_color_no_tty(): |
38 | 39 | def test_use_color_tty_with_color_support(): |
39 | 40 | with mock.patch.object(sys.stdout, 'isatty', return_value=True): |
40 | 41 | with mock.patch('pre_commit.color.terminal_supports_color', True): |
41 | | - assert use_color('auto') is True |
| 42 | + with envcontext.envcontext([('TERM', envcontext.UNSET)]): |
| 43 | + assert use_color('auto') is True |
42 | 44 |
|
43 | 45 |
|
44 | 46 | def test_use_color_tty_without_color_support(): |
45 | 47 | with mock.patch.object(sys.stdout, 'isatty', return_value=True): |
46 | 48 | with mock.patch('pre_commit.color.terminal_supports_color', False): |
47 | | - assert use_color('auto') is False |
| 49 | + with envcontext.envcontext([('TERM', envcontext.UNSET)]): |
| 50 | + assert use_color('auto') is False |
| 51 | + |
| 52 | + |
| 53 | +def test_use_color_dumb_term(): |
| 54 | + with mock.patch.object(sys.stdout, 'isatty', return_value=True): |
| 55 | + with mock.patch('pre_commit.color.terminal_supports_color', True): |
| 56 | + with envcontext.envcontext([('TERM', 'dumb')]): |
| 57 | + assert use_color('auto') is False |
48 | 58 |
|
49 | 59 |
|
50 | 60 | def test_use_color_raises_if_given_shenanigans(): |
|
0 commit comments