aboutsummaryrefslogtreecommitdiff
path: root/tests/test_logging.py
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-11-01 11:33:13 -0700
committerCody Logan <cody@lokken.dev>2023-11-01 11:42:43 -0700
commitf61853c366a1554f545b34783e1aa282022598b9 (patch)
treec0b5bd30f23183cd81f67622c3534e0ee5417bee /tests/test_logging.py
parent8b923f0cee8fed90d6eef313429eb593877e0f2d (diff)
downloadwikiget-f61853c366a1554f545b34783e1aa282022598b9.tar.gz
wikiget-f61853c366a1554f545b34783e1aa282022598b9.zip
Add some explanatory comments to tests
Diffstat (limited to 'tests/test_logging.py')
-rw-r--r--tests/test_logging.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_logging.py b/tests/test_logging.py
index d02df62..b5ee6a0 100644
--- a/tests/test_logging.py
+++ b/tests/test_logging.py
@@ -27,6 +27,9 @@ logger = logging.getLogger()
def test_custom_log_adapter(caplog: LogCaptureFixture) -> None:
+ """
+ The custom log adapter should prepend the filename to log messages.
+ """
args = construct_parser().parse_args(["File:Example.jpg"])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
adapter = FileLogAdapter(logger, {"filename": "Example.jpg"})
@@ -35,6 +38,9 @@ def test_custom_log_adapter(caplog: LogCaptureFixture) -> None:
def test_file_logging(tmp_path: Path) -> None:
+ """
+ Logging to a file should create the file in the specified location.
+ """
logfile_location = tmp_path / "test.log"
args = construct_parser().parse_args(
["File:Example.jpg", "-l", str(logfile_location)]
@@ -44,6 +50,9 @@ def test_file_logging(tmp_path: Path) -> None:
def test_default_logging() -> None:
+ """
+ The default log level should be set to WARNING.
+ """
args = construct_parser().parse_args(["File:Example.jpg"])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
# each call of configure_logging() adds a new handler to the logger, so we need to
@@ -53,6 +62,9 @@ def test_default_logging() -> None:
def test_verbose_logging() -> None:
+ """
+ When -v is passed, the log level should be set to INFO.
+ """
args = construct_parser().parse_args(["File:Example.jpg", "-v"])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
handler = logger.handlers[-1]
@@ -60,6 +72,9 @@ def test_verbose_logging() -> None:
def test_very_verbose_logging() -> None:
+ """
+ When -vv is passed, the log level should be set to DEBUG.
+ """
args = construct_parser().parse_args(["File:Example.jpg", "-vv"])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
handler = logger.handlers[-1]
@@ -67,6 +82,9 @@ def test_very_verbose_logging() -> None:
def test_quiet_logging() -> None:
+ """
+ When -q is passed, the log level should be set to ERROR.
+ """
args = construct_parser().parse_args(["File:Example.jpg", "-q"])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
handler = logger.handlers[-1]