Skip to content

Commit cdad974

Browse files
committed
✅ Add --debug-simvue flag for enabling DEBUG log messages in tests
1 parent 3e9c146 commit cdad974

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/conftest.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
MAX_BUFFER_SIZE: int = 10
2727

28+
def pytest_addoption(parser):
29+
parser.addoption("--debug-simvue", action="store_true", default=False)
30+
31+
2832
class CountingLogHandler(logging.Handler):
2933
def __init__(self, level=logging.DEBUG):
3034
super().__init__(level)
@@ -48,6 +52,7 @@ def clear_out_files() -> None:
4852

4953
for file_obj in out_files:
5054
file_obj.unlink()
55+
5156

5257
@pytest.fixture()
5358
def offline_cache_setup(monkeypatch: monkeypatch.MonkeyPatch):
@@ -113,11 +118,11 @@ def speedy_heartbeat(monkeypatch: monkeypatch.MonkeyPatch) -> None:
113118

114119

115120
@pytest.fixture(autouse=True)
116-
def setup_logging() -> CountingLogHandler:
117-
logging.basicConfig(level=logging.DEBUG)
121+
def setup_logging(pytestconfig) -> CountingLogHandler:
122+
logging.basicConfig(level=logging.WARNING)
118123
handler = CountingLogHandler()
119-
logging.getLogger().setLevel(logging.DEBUG)
120-
logging.getLogger().addHandler(handler)
124+
logging.getLogger("simvue").setLevel(logging.DEBUG if pytestconfig.getoption("debug_simvue") else logging.WARNING)
125+
logging.getLogger("simvue").addHandler(handler)
121126
return handler
122127

123128

0 commit comments

Comments
 (0)