Skip to content

Commit

Permalink
tests: support running tests with NO_COLOR (#407)
Browse files Browse the repository at this point in the history
Fix #405.

---------

Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Jun 23, 2023
1 parent 2cfa180 commit 363c992
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@

def test_rich_print_nocolor(capsys, monkeypatch):
monkeypatch.setenv("NO_COLOR", "1")
monkeypatch.delenv("FORCE_COLOR", raising=False)
rich_print("[red]hello[/red] world", end="")
assert capsys.readouterr().out == "hello world"


def test_rich_print_nocolor_forcecolor(capsys, monkeypatch):
monkeypatch.setenv("NO_COLOR", "1")
monkeypatch.setenv("FORCE_COLOR", "1")
rich_print("[red]hello[/red] world", end="")
assert capsys.readouterr().out == "hello world"


def test_rich_print_forcecolor(capsys, monkeypatch):
monkeypatch.setenv("FORCE_COLOR", "1")
monkeypatch.delenv("NO_COLOR", raising=False)
rich_print("[red bold]hello[/bold] world", end="")
assert capsys.readouterr().out == "\33[91m\33[1mhello\33[22m world\33[0m"

0 comments on commit 363c992

Please sign in to comment.