diff options
| author | Cody Logan <cody@lokken.dev> | 2023-11-01 11:55:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-01 11:55:44 -0700 |
| commit | 15ffefbd0ca80f240b5468b4ab5cea5e9800ad83 (patch) | |
| tree | c0b5bd30f23183cd81f67622c3534e0ee5417bee /tests/test_logging.py | |
| parent | e11e6ec4fc6180f2ffc4905b2561ecc385a29e5d (diff) | |
| parent | 823171ba0bf42766446509f0143b95078285a1f0 (diff) | |
| download | wikiget-15ffefbd0ca80f240b5468b4ab5cea5e9800ad83.tar.gz wikiget-15ffefbd0ca80f240b5468b4ab5cea5e9800ad83.zip | |
Merge pull request #11 from clpo13/add-tests
Add and improve some tests
Diffstat (limited to 'tests/test_logging.py')
| -rw-r--r-- | tests/test_logging.py | 18 |
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] |
