Skip to content

Commit 4ab4bb0

Browse files
committed
test: add a test for env var truncation
1 parent bf1a970 commit 4ab4bb0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

coverage/debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def should(self, option: str) -> bool:
124124
@contextlib.contextmanager
125125
def without_callers(self) -> Iterator[None]:
126126
"""A dummy context manager to satisfy the api."""
127-
yield
127+
yield # pragma: never called
128128

129129
def write(self, msg: str, *, exc: BaseException | None = None) -> None:
130130
"""This will never be called."""

tests/test_debug.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ def test_short_filename(self) -> None:
421421
assert short_filename(None) is None
422422

423423

424-
def test_relevant_environment_display() -> None:
424+
@pytest.mark.parametrize("long_len", [10, 100])
425+
def test_relevant_environment_display(long_len: int) -> None:
425426
env_vars = {
426427
"HOME": "my home",
427428
"HOME_DIR": "other place",
@@ -430,8 +431,14 @@ def test_relevant_environment_display() -> None:
430431
"COVERAGE_THING": "abcd",
431432
"MY_PYPI_TOKEN": "secret.something",
432433
"TMP": "temporary",
434+
"COVERAGE_PROCESS_CONFIG": "abc" + "x" * (long_len - 3),
433435
}
436+
long_val = {
437+
10: "abcxxxxxxx",
438+
100: "abc" + "x" * (60 - 3 - 3) + "...",
439+
}[long_len]
434440
expected = [
441+
("COVERAGE_PROCESS_CONFIG", long_val),
435442
("COVERAGE_THING", "abcd"),
436443
("HOME", "my home"),
437444
("MY_PYPI_TOKEN", "******.*********"),

0 commit comments

Comments
 (0)