-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |