From 85204550425b69990c0c3b28e66296b013901a33 Mon Sep 17 00:00:00 2001 From: Edgar Geier Date: Mon, 22 Jul 2019 20:07:16 +0200 Subject: [PATCH] Add tests for NO_COLOR support --- tests/color_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/color_test.py b/tests/color_test.py index 6e11765c..fb311c85 100644 --- a/tests/color_test.py +++ b/tests/color_test.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +import os import sys import mock @@ -50,3 +51,20 @@ def test_use_color_tty_without_color_support(): def test_use_color_raises_if_given_shenanigans(): with pytest.raises(InvalidColorSetting): use_color('herpaderp') + + +def test_no_color_env_unset(): + with mock.patch.dict(os.environ): + if 'NO_COLOR' in os.environ: + del os.environ['NO_COLOR'] + assert use_color('always') is True + + +def test_no_color_env_empty(): + with mock.patch.dict(os.environ, NO_COLOR=''): + assert use_color('always') is True + + +def test_no_color_env_non_empty(): + with mock.patch.dict(os.environ, NO_COLOR=' '): + assert use_color('always') is False