Skip to content

Commit

Permalink
tests: Ensure we don't get escape codes even with FORCE_COLOR
Browse files Browse the repository at this point in the history
  • Loading branch information
zerario committed Jan 12, 2024
1 parent 85dda23 commit 652f40f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 5 additions & 3 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def patcher_cli_name(

class TestInit:
@pytest.fixture
def runner_noenv(self, credentials: FakeCredentials) -> Runner:
"""Runner with no env variables set."""
return Runner(credentials.SHARECODE)
def runner_noenv(self, runner: Runner, monkeypatch: pytest.MonkeyPatch) -> Runner:
"""Runner with no auth env variables set."""
monkeypatch.delenv(cli.API_USER_ENV_VAR)
monkeypatch.delenv(cli.API_KEY_ENV_VAR)
return runner

@pytest.mark.parametrize("valid", [True, False])
def test_init(
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ def run(self, *args: str) -> click.testing.Result:

@pytest.fixture
def runner(monkeypatch: pytest.MonkeyPatch, credentials: FakeCredentials) -> Runner:
rich.reconfigure(width=80, no_color=True)
monkeypatch.setenv("COLUMNS", "80") # for future console instances
monkeypatch.setenv("NO_COLOR", "1")
rich.reconfigure(width=80, force_terminal=False)
# for future console instances
monkeypatch.setenv("COLUMNS", "80")
monkeypatch.setenv("TERM", "dumb")
monkeypatch.setenv(cli.API_USER_ENV_VAR, credentials.USERNAME)
monkeypatch.setenv(cli.API_KEY_ENV_VAR, credentials.API_KEY)
return Runner(credentials.SHARECODE)
Expand Down

0 comments on commit 652f40f

Please sign in to comment.