diff options
author | Tim Peters <tim.peters@gmail.com> | 2005-12-30 20:46:23 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2005-12-30 20:46:23 (GMT) |
commit | 0cdc3d884ef0ac7a19446680e135b606875c12e4 (patch) | |
tree | e1cf50cffe060421f281cd99b241b752c27131e3 | |
parent | 1b27f86411f2593fe6137c54143c0d23f21271c7 (diff) | |
download | cpython-0cdc3d884ef0ac7a19446680e135b606875c12e4.zip cpython-0cdc3d884ef0ac7a19446680e135b606875c12e4.tar.gz cpython-0cdc3d884ef0ac7a19446680e135b606875c12e4.tar.bz2 |
test_main(): Restore the original root logger level after running
the tests. This stops the confusing/annoying:
No handlers could be found for logger "cookielib"
message we got whenever some test running after test_logging
happened to use cookielib.py (when not using regrtest's -r,
this happened during test_urllib2; when using -r, it varied).
-rw-r--r-- | Lib/test/test_logging.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 64ca571..62c0b08 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -487,11 +487,20 @@ def test_main(): # or a Mac OS X box which supports very little locale stuff at all original_locale = None + # Save and restore the original root logger level across the tests. + # Otherwise, e.g., if any test using cookielib runs after test_logging, + # cookielib's debug-level logger tries to log messages, leading to + # confusing: + # No handlers could be found for logger "cookielib" + # output while the tests are running. + root_logger = logging.getLogger("") + original_logging_level = root_logger.getEffectiveLevel() try: test_main_inner() finally: if original_locale is not None: locale.setlocale(locale.LC_ALL, original_locale) + root_logger.setLevel(original_logging_level) if __name__ == "__main__": sys.stdout.write("test_logging\n") |