Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix running tests in environment with NO_COLOR=1
Browse files Browse the repository at this point in the history
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.
mgorny committed Nov 24, 2023
1 parent 8390e75 commit 4babdb5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions colorlog/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -28,6 +28,13 @@ def assert_log_message(capsys, log_function, message, *args):
return err


@pytest.fixture(autouse=True)
def clean_env(monkeypatch):
monkeypatch.delenv("FORCE_COLOR", raising=False)
monkeypatch.delenv("NO_COLOR", raising=False)
yield


@pytest.fixture()
def reset_loggers():
logging.root.handlers = list()

0 comments on commit 4babdb5

Please sign in to comment.