test_logging_error: build a logger at the test level
test_logging_error calls getLogger at the module level and thus a logger gets permanently inserted into the _loggers dict and is visible in all other tests. As tests shouldn't affect each other, a logger creation should be moved to the TestLoggingFixture class setUp method. Change-Id: I8e988c88cc1ffaf53bd3c97607f16fc2a8078d12
This commit is contained in:
parent
fcf3115539
commit
fe2ac659ce
@ -15,14 +15,17 @@ from oslo_log import fixture
|
||||
from oslo_log import log as logging
|
||||
from oslotest import base as test_base
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestLoggingFixture(test_base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestLoggingFixture, self).setUp()
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
||||
def test_logging_handle_error(self):
|
||||
LOG.error('pid of first child is %(foo)s', 1)
|
||||
self.log.error('pid of first child is %(foo)s', 1)
|
||||
self.useFixture(fixture.get_logging_handle_error_fixture())
|
||||
self.assertRaises(TypeError,
|
||||
LOG.error,
|
||||
self.log.error,
|
||||
'pid of first child is %(foo)s',
|
||||
1)
|
||||
|
Loading…
Reference in New Issue
Block a user