Skip to content

Commit

Permalink
Increase test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Adam.Dybbroe <[email protected]>
  • Loading branch information
Adam.Dybbroe committed Nov 21, 2024
1 parent 1d480df commit 721c7b5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pyorbital/tests/test_logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2024 Pytroll Community

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Test the logging module."""

import logging

from pyorbital.logger import get_logger, logging_off, logging_on


def test_logging_on_and_off(caplog):
"""Test that switching logging on and off works."""
logger = get_logger("pyorbital.spam")
logging_on()
with caplog.at_level(logging.WARNING):
logger.debug("I'd like to leave the army please, sir.")
logger.warning("Stop that! It's SPAM.")
assert "Stop that! It's SPAM" in caplog.text
assert "I'd like to leave the army please, sir." not in caplog.text
logging_off()
with caplog.at_level(logging.DEBUG):
logger.warning("You've got a nice army base here, Colonel.")
assert "You've got a nice army base here, Colonel." not in caplog.text

0 comments on commit 721c7b5

Please sign in to comment.