Skip to content

Commit 6a14458

Browse files
mgornyborntyping
authored andcommitted
Fix running tests in environment with NO_COLOR=1
Fix running the test suite when pytest is run with NO_COLOR=1 set in the environment. An fixture is autoused to ensure that the variables are removed for the scope of the test, while they are respected e.g. by pytest itself.
1 parent 83b292b commit 6a14458

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

colorlog/tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ def assert_log_message(capsys, log_function, message, *args):
2828
return err
2929

3030

31+
@pytest.fixture(autouse=True)
32+
def clean_env(monkeypatch):
33+
monkeypatch.delenv("FORCE_COLOR", raising=False)
34+
monkeypatch.delenv("NO_COLOR", raising=False)
35+
36+
3137
@pytest.fixture()
3238
def reset_loggers():
3339
logging.root.handlers = list()

0 commit comments

Comments
 (0)