diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-02-07 01:37:08 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-02-07 01:37:08 (GMT) |
commit | 657514a69039ad60af1b3b98254dff863d800d95 (patch) | |
tree | af6171e5f24cc66c1dc36526cd1d2605a5393e8f /Lib/test | |
parent | 12cad204a0e9f026c5a4f4d486e059d51af7cd92 (diff) | |
download | cpython-657514a69039ad60af1b3b98254dff863d800d95.zip cpython-657514a69039ad60af1b3b98254dff863d800d95.tar.gz cpython-657514a69039ad60af1b3b98254dff863d800d95.tar.bz2 |
Issue #7868: logging: added loggerClass attribute to Manager.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_logging.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index b9825cd..0ef66a0 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -1593,7 +1593,6 @@ class ConfigDictTest(BaseTest): logging.config.stopListening() t.join(2.0) - #@unittest.skip("See issue #7857") def test_listen_config_10_ok(self): with captured_stdout() as output: self.setup_via_listener(json.dumps(self.config10)) @@ -1613,7 +1612,6 @@ class ConfigDictTest(BaseTest): ('ERROR', '4'), ], stream=output) - #@unittest.skip("See issue #7857") def test_listen_config_1_ok(self): with captured_stdout() as output: self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1)) @@ -1629,15 +1627,34 @@ class ConfigDictTest(BaseTest): self.assert_log_lines([]) +class ManagerTest(BaseTest): + def test_manager_loggerclass(self): + logged = [] + + class MyLogger(logging.Logger): + def _log(self, level, msg, args, exc_info=None, extra=None): + logged.append(msg) + + man = logging.Manager(None) + self.assertRaises(TypeError, man.setLoggerClass, int) + man.setLoggerClass(MyLogger) + logger = man.getLogger('test') + print >> open('/tmp/tmp.txt', 'w'), type(logger) + logger.warning('should appear in logged') + logging.warning('should not appear in logged') + + self.assertEqual(logged, ['should appear in logged']) + + # Set the locale to the platform-dependent default. I have no idea # why the test does this, but in any case we save the current locale # first and restore it at the end. @run_with_locale('LC_ALL', '') def test_main(): run_unittest(BuiltinLevelsTest, BasicFilterTest, - CustomLevelsAndFiltersTest, MemoryHandlerTest, - ConfigFileTest, SocketHandlerTest, MemoryTest, - EncodingTest, WarningsTest, ConfigDictTest) + CustomLevelsAndFiltersTest, MemoryHandlerTest, + ConfigFileTest, SocketHandlerTest, MemoryTest, + EncodingTest, WarningsTest, ConfigDictTest, ManagerTest) if __name__ == "__main__": test_main() |