blob: 5bc725a4d82e4e57f1e03913634decada8201a44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import logging
import unittest
from nose.config import Config
#from nose.core import configure_logging
from mock import *
class TestLoggingConfig(unittest.TestCase):
def setUp(self):
# install mock root logger so that these tests don't stomp on
# the real logging config of the test runner
class MockLogger(logging.Logger):
root = logging.RootLogger(logging.WARNING)
manager = logging.Manager(root)
self.real_logger = logging.Logger
self.real_root = logging.root
logging.Logger = MockLogger
logging.root = MockLogger.root
def tearDown(self):
# reset real root logger
logging.Logger = self.real_logger
logging.root = self.real_root
def test_isolation(self):
"""root logger settings ignored"""
root = logging.getLogger('')
nose = logging.getLogger('nose')
opt = Bucket()
configure_logging(opt)
root.setLevel(logging.DEBUG)
self.assertEqual(nose.level, logging.WARN)
if __name__ == '__main__':
unittest.main()
|