-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit warning on incorrect Objective name
- Loading branch information
あで
committed
Nov 10, 2023
1 parent
0535e75
commit 9d3d61d
Showing
3 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import logging | ||
|
||
from autometrics.objectives import Objective | ||
|
||
|
||
def test_objective_name_warning(caplog): | ||
"""Test that a warning is logged when an objective name contains invalid characters.""" | ||
caplog.set_level(logging.WARNING) | ||
caplog.clear() | ||
Objective("Incorrect name.") | ||
assert len(caplog.records) == 1 | ||
assert caplog.records[0].levelname == "WARNING" | ||
assert "contains invalid characters" in caplog.records[0].message | ||
caplog.clear() | ||
Objective("correct-name-123") | ||
assert len(caplog.records) == 0 |