Skip to content

Commit 1f016f8

Browse files
committed
improv: add test on env var as int
1 parent a6222e2 commit 1f016f8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/functional/test_logger.py

+11
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,14 @@ def test_logger_level_as_int():
333333

334334
# THEN we should be expected int (20, in this case)
335335
assert logger.level == logging.INFO
336+
337+
338+
def test_logger_level_env_var_as_int(monkeypatch):
339+
# GIVEN Logger is initialized
340+
# WHEN log level is explicitly defined via LOG_LEVEL env as int
341+
# THEN Logger should propagate ValueError
342+
# since env vars can only be string
343+
# and '50' is not a correct log level
344+
monkeypatch.setenv("LOG_LEVEL", 50)
345+
with pytest.raises(ValueError, match="Unknown level: '50'"):
346+
Logger()

0 commit comments

Comments
 (0)