Skip to content

Commit

Permalink
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.
  • Loading branch information
mgorny committed Nov 24, 2023
1 parent 8390e75 commit c2a5039
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions colorlog/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ 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)


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

0 comments on commit c2a5039

Please sign in to comment.