Skip to content

Commit 84d3b6a

Browse files
committed
TST: minor fixes
1 parent 3260573 commit 84d3b6a

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tests/unit/test_logging.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@
1010

1111
@pytest.fixture(autouse=True)
1212
def _restore_logger_state():
13-
"""Snapshot and restore the rocketpy logger so tests don't leak state."""
13+
"""Snapshot and restore the rocketpy logger so tests don't leak state.
14+
15+
Other tests (e.g. verbose ``Flight`` runs, which call ``enable_logging``)
16+
may have attached the console handler to the shared logger and left it
17+
there. Strip it before each test so these tests start from the library's
18+
default state, then restore the original handlers afterwards.
19+
"""
1420
saved_handlers = logger.handlers[:]
1521
saved_level = logger.level
22+
logger.handlers[:] = [
23+
h
24+
for h in logger.handlers
25+
if getattr(h, "name", None) != "rocketpy_console_handler"
26+
]
1627
yield
1728
logger.handlers[:] = saved_handlers
1829
logger.setLevel(saved_level)

0 commit comments

Comments
 (0)