From 4db37d7ab5606f1e0b6f02b89fdaa04f5b96e6f5 Mon Sep 17 00:00:00 2001 From: Lars Mikkelsen Date: Tue, 27 Oct 2020 20:18:44 -0400 Subject: [PATCH] Fix log-level option --- icloudpd/logger.py | 5 ++--- tests/test_cli.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/icloudpd/logger.py b/icloudpd/logger.py index 2b812a487..927a0cbae 100644 --- a/icloudpd/logger.py +++ b/icloudpd/logger.py @@ -2,7 +2,7 @@ import sys import logging -from logging import DEBUG, INFO +from logging import INFO class IPDLogger(logging.Logger): @@ -32,11 +32,10 @@ def tqdm_write(self, message, loglevel=INFO): self.tqdm.write(message) -def setup_logger(loglevel=DEBUG): +def setup_logger(): """Set up logger and add stdout handler""" logging.setLoggerClass(IPDLogger) logger = logging.getLogger("icloudpd") - logger.setLevel(loglevel) has_stdout_handler = False for handler in logger.handlers: if handler.name == "stdoutLogger": diff --git a/tests/test_cli.py b/tests/test_cli.py index b42358006..71803732a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,6 +3,7 @@ import os import shutil from vcr import VCR +import pytest from click.testing import CliRunner from icloudpd.base import main @@ -10,6 +11,10 @@ class CliTestCase(TestCase): + @pytest.fixture(autouse=True) + def inject_fixtures(self, caplog): + self._caplog = caplog + def test_cli(self): runner = CliRunner() result = runner.invoke(main, ["--help"]) @@ -37,8 +42,11 @@ def test_log_levels(self): "tests/fixtures/Photos", ], ) + self.assertNotIn("DEBUG", self._caplog.text) + self.assertIn("INFO", self._caplog.text) assert result.exit_code == 0 with vcr.use_cassette("tests/vcr_cassettes/listing_photos.yml"): + self._caplog.clear() result = runner.invoke( main, [ @@ -54,6 +62,8 @@ def test_log_levels(self): "tests/fixtures/Photos", ], ) + self.assertNotIn("DEBUG", self._caplog.text) + self.assertNotIn("INFO", self._caplog.text) assert result.exit_code == 0 def test_tqdm(self):