diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-04-11 07:42:07 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-04-11 07:42:07 (GMT) |
commit | 4a0a31df5c6ab79dd7dc8ee828379dca1d1f632f (patch) | |
tree | 0246d7ef13a693a1194cbed38f1df9697f720735 /Lib/test/test_logging.py | |
parent | 98707c2cede1aa697a1338ea8f7c9a59da42dfe9 (diff) | |
download | cpython-4a0a31df5c6ab79dd7dc8ee828379dca1d1f632f.zip cpython-4a0a31df5c6ab79dd7dc8ee828379dca1d1f632f.tar.gz cpython-4a0a31df5c6ab79dd7dc8ee828379dca1d1f632f.tar.bz2 |
Added 'handlers' argument to logging.basicConfig.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r-- | Lib/test/test_logging.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 18222ea..88f0ebc 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -2482,6 +2482,26 @@ class BasicConfigTest(unittest.TestCase): logging.basicConfig(level=57) self.assertEqual(logging.root.level, 57) + def test_incompatible(self): + assertRaises = self.assertRaises + handlers = [logging.StreamHandler()] + stream = sys.stderr + assertRaises(ValueError, logging.basicConfig, filename='test.log', + stream=stream) + assertRaises(ValueError, logging.basicConfig, filename='test.log', + handlers=handlers) + assertRaises(ValueError, logging.basicConfig, stream=stream, + handlers=handlers) + + def test_handlers(self): + handlers = [logging.StreamHandler(), logging.StreamHandler(sys.stdout)] + logging.basicConfig(handlers=handlers) + self.assertIs(handlers[0], logging.root.handlers[0]) + self.assertIs(handlers[1], logging.root.handlers[1]) + self.assertIsNotNone(handlers[0].formatter) + self.assertIsNotNone(handlers[1].formatter) + self.assertIs(handlers[0].formatter, handlers[1].formatter) + def _test_log(self, method, level=None): # logging.root has no handlers so basicConfig should be called called = [] |