Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing unknown int log levels #40

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions logot/_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
def validate_levelno(level: int | str) -> int:
# Handle `int` level.
if isinstance(level, int):
if logging.getLevelName(level).startswith("Level "):
raise ValueError(f"Unknown level: {level!r}")
return level
# Handle `str` level.
if isinstance(level, str):
Expand Down
6 changes: 0 additions & 6 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ def test_validate_levelno_int_pass() -> None:
assert validate_levelno(logging.INFO) == logging.INFO


def test_validate_levelno_int_fail() -> None:
with pytest.raises(ValueError) as ex:
validate_levelno(9999)
assert str(ex.value) == "Unknown level: 9999"


def test_validate_levelno_str_pass() -> None:
assert validate_levelno("INFO") == logging.INFO

Expand Down