generated from childmindresearch/template-python-repository
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from childmindresearch/feature/issue-62/add-lo…
…gger Feature/issue 62/add logger
- Loading branch information
Showing
5 changed files
with
112 additions
and
13 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
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,29 @@ | ||
"""Test logging in config.py.""" | ||
|
||
import pytest | ||
|
||
from wristpy.core import config | ||
|
||
|
||
def test_get_logger(caplog: pytest.LogCaptureFixture) -> None: | ||
"""Test the wristpy logger with level set to 20 (info).""" | ||
logger = config.get_logger() | ||
|
||
logger.debug("Debug message here.") | ||
logger.info("Info message here.") | ||
logger.warning("Warning message here.") | ||
|
||
assert logger.getEffectiveLevel() == 20 | ||
assert "Debug message here" not in caplog.text | ||
assert "Info message here." in caplog.text | ||
assert "Warning message here." in caplog.text | ||
|
||
|
||
def test_get_logger_second_call() -> None: | ||
"""Test get logger when a handler already exists.""" | ||
logger = config.get_logger() | ||
second_logger = config.get_logger() | ||
|
||
assert len(logger.handlers) == len(second_logger.handlers) == 1 | ||
assert logger.handlers[0] is second_logger.handlers[0] | ||
assert logger is second_logger |