aboutsummaryrefslogtreecommitdiff
path: root/tests/test_logging.py
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-11-01 13:11:35 -0700
committerCody Logan <cody@lokken.dev>2023-11-01 13:11:35 -0700
commitbf7d8c97620471fed7e9276462984b1f33b512d0 (patch)
tree006e0a99b4e9c06028e9192cf6da33a68b59329f /tests/test_logging.py
parent235b3e6a723e3e18962212c7d2c0f19619c2fa6f (diff)
downloadwikiget-bf7d8c97620471fed7e9276462984b1f33b512d0.tar.gz
wikiget-bf7d8c97620471fed7e9276462984b1f33b512d0.zip
Condense parser construction logic
Diffstat (limited to 'tests/test_logging.py')
-rw-r--r--tests/test_logging.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/tests/test_logging.py b/tests/test_logging.py
index b5ee6a0..4e0428e 100644
--- a/tests/test_logging.py
+++ b/tests/test_logging.py
@@ -30,7 +30,7 @@ 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"])
+ args = construct_parser(["File:Example.jpg"])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
adapter = FileLogAdapter(logger, {"filename": "Example.jpg"})
adapter.warning("test log")
@@ -42,9 +42,7 @@ 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)]
- )
+ args = construct_parser(["File:Example.jpg", "-l", str(logfile_location)])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
assert logfile_location.is_file()
@@ -53,7 +51,7 @@ def test_default_logging() -> None:
"""
The default log level should be set to WARNING.
"""
- args = construct_parser().parse_args(["File:Example.jpg"])
+ args = construct_parser(["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
# grab the most recently added one to test
@@ -65,7 +63,7 @@ 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"])
+ args = construct_parser(["File:Example.jpg", "-v"])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
handler = logger.handlers[-1]
assert handler.level == logging.INFO
@@ -75,7 +73,7 @@ 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"])
+ args = construct_parser(["File:Example.jpg", "-vv"])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
handler = logger.handlers[-1]
assert handler.level == logging.DEBUG
@@ -85,7 +83,7 @@ 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"])
+ args = construct_parser(["File:Example.jpg", "-q"])
configure_logging(args.verbose, args.logfile, quiet=args.quiet)
handler = logger.handlers[-1]
assert handler.level == logging.ERROR