Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8520455

Browse files
committed
Add tests for NO_COLOR support
1 parent 01d3a72 commit 8520455

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/color_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import unicode_literals
22

3+
import os
34
import sys
45

56
import mock
@@ -50,3 +51,20 @@ def test_use_color_tty_without_color_support():
5051
def test_use_color_raises_if_given_shenanigans():
5152
with pytest.raises(InvalidColorSetting):
5253
use_color('herpaderp')
54+
55+
56+
def test_no_color_env_unset():
57+
with mock.patch.dict(os.environ):
58+
if 'NO_COLOR' in os.environ:
59+
del os.environ['NO_COLOR']
60+
assert use_color('always') is True
61+
62+
63+
def test_no_color_env_empty():
64+
with mock.patch.dict(os.environ, NO_COLOR=''):
65+
assert use_color('always') is True
66+
67+
68+
def test_no_color_env_non_empty():
69+
with mock.patch.dict(os.environ, NO_COLOR=' '):
70+
assert use_color('always') is False

0 commit comments

Comments
 (0)