Skip to content

Commit 8f27752

Browse files
committed
test(cli): Fix conflicting logging fixtures between test files
why: Test suite was failing when run together due to fixture conflicts what: - Add vcspull.cli.fmt to list of loggers cleared in fixtures - Rename clear_logging_handlers to reset_logging in test_fmt.py to avoid conflicts - Update test_fmt.py tests to use reset_logging fixture refs: Fixture isolation issue - clear_logging_handlers with autouse=True affects all tests
1 parent a7a8a39 commit 8f27752

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

tests/cli/test_add.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def clear_logging_handlers() -> t.Generator[None, None, None]:
3030
"vcspull.cli.add",
3131
"vcspull.cli.add_from_fs",
3232
"vcspull.cli.sync",
33+
"vcspull.cli.fmt",
3334
]
3435
for logger_name in cli_loggers:
3536
logger = logging.getLogger(logger_name)

tests/cli/test_add_from_fs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def clear_logging_handlers() -> t.Generator[None, None, None]:
3232
"vcspull.cli.add",
3333
"vcspull.cli.add_from_fs",
3434
"vcspull.cli.sync",
35+
"vcspull.cli.fmt",
3536
]
3637
for logger_name in cli_loggers:
3738
logger = logging.getLogger(logger_name)

tests/cli/test_fmt.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717

1818
@pytest.fixture
19-
def clear_logging_handlers() -> t.Generator[None, None, None]:
20-
"""Clear logging handlers to prevent duplicate log messages in tests."""
19+
def reset_logging() -> t.Generator[None, None, None]:
20+
"""Reset logging handlers to prevent duplicate log messages in tests."""
2121
# Store original handlers
2222
original_handlers = logging.root.handlers[:]
2323
# Clear all handlers
@@ -181,7 +181,7 @@ def test_format_file_no_write(
181181
self,
182182
tmp_path: pathlib.Path,
183183
caplog: LogCaptureFixture,
184-
clear_logging_handlers: None,
184+
reset_logging: None,
185185
) -> None:
186186
"""Test formatting without writing changes."""
187187
config_file = tmp_path / ".vcspull.yaml"
@@ -214,7 +214,7 @@ def test_format_file_with_write(
214214
self,
215215
tmp_path: pathlib.Path,
216216
caplog: LogCaptureFixture,
217-
clear_logging_handlers: None,
217+
reset_logging: None,
218218
) -> None:
219219
"""Test formatting with writing changes."""
220220
config_file = tmp_path / ".vcspull.yaml"
@@ -252,7 +252,7 @@ def test_already_formatted(
252252
self,
253253
tmp_path: pathlib.Path,
254254
caplog: LogCaptureFixture,
255-
clear_logging_handlers: None,
255+
reset_logging: None,
256256
) -> None:
257257
"""Test when file is already correctly formatted."""
258258
config_file = tmp_path / ".vcspull.yaml"
@@ -277,7 +277,7 @@ def test_nonexistent_file(
277277
self,
278278
tmp_path: pathlib.Path,
279279
caplog: LogCaptureFixture,
280-
clear_logging_handlers: None,
280+
reset_logging: None,
281281
) -> None:
282282
"""Test handling of nonexistent config file."""
283283
config_file = tmp_path / "nonexistent.yaml"
@@ -291,7 +291,7 @@ def test_invalid_yaml(
291291
self,
292292
tmp_path: pathlib.Path,
293293
caplog: LogCaptureFixture,
294-
clear_logging_handlers: None,
294+
reset_logging: None,
295295
) -> None:
296296
"""Test handling of invalid YAML."""
297297
config_file = tmp_path / ".vcspull.yaml"
@@ -307,7 +307,7 @@ def test_no_config_found(
307307
tmp_path: pathlib.Path,
308308
caplog: LogCaptureFixture,
309309
monkeypatch: pytest.MonkeyPatch,
310-
clear_logging_handlers: None,
310+
reset_logging: None,
311311
) -> None:
312312
"""Test when no config file is found."""
313313
monkeypatch.chdir(tmp_path)
@@ -321,7 +321,7 @@ def test_detailed_change_reporting(
321321
self,
322322
tmp_path: pathlib.Path,
323323
caplog: LogCaptureFixture,
324-
clear_logging_handlers: None,
324+
reset_logging: None,
325325
) -> None:
326326
"""Test detailed reporting of changes."""
327327
config_file = tmp_path / ".vcspull.yaml"

0 commit comments

Comments
 (0)