Skip to content

Commit 652f40f

Browse files
committed
tests: Ensure we don't get escape codes even with FORCE_COLOR
See tox-dev/tox#3172
1 parent 85dda23 commit 652f40f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

tests/cli/test_cli.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ def patcher_cli_name(
4141

4242
class TestInit:
4343
@pytest.fixture
44-
def runner_noenv(self, credentials: FakeCredentials) -> Runner:
45-
"""Runner with no env variables set."""
46-
return Runner(credentials.SHARECODE)
44+
def runner_noenv(self, runner: Runner, monkeypatch: pytest.MonkeyPatch) -> Runner:
45+
"""Runner with no auth env variables set."""
46+
monkeypatch.delenv(cli.API_USER_ENV_VAR)
47+
monkeypatch.delenv(cli.API_KEY_ENV_VAR)
48+
return runner
4749

4850
@pytest.mark.parametrize("valid", [True, False])
4951
def test_init(

tests/conftest.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ def run(self, *args: str) -> click.testing.Result:
7979

8080
@pytest.fixture
8181
def runner(monkeypatch: pytest.MonkeyPatch, credentials: FakeCredentials) -> Runner:
82-
rich.reconfigure(width=80, no_color=True)
83-
monkeypatch.setenv("COLUMNS", "80") # for future console instances
84-
monkeypatch.setenv("NO_COLOR", "1")
82+
rich.reconfigure(width=80, force_terminal=False)
83+
# for future console instances
84+
monkeypatch.setenv("COLUMNS", "80")
85+
monkeypatch.setenv("TERM", "dumb")
8586
monkeypatch.setenv(cli.API_USER_ENV_VAR, credentials.USERNAME)
8687
monkeypatch.setenv(cli.API_KEY_ENV_VAR, credentials.API_KEY)
8788
return Runner(credentials.SHARECODE)

0 commit comments

Comments
 (0)