remove unnecessary message when running unit test
When we test log related code, we still print the tested log message into stderr, which is not quite useful for developers, we should mock those message. Package fixtures.FakeLogger already provides an option to mock specified logger, so let's use it. Note: this patch also changes an unnecessary object attribute to local varible. Change-Id: I4bc5beaa4eba149f12c58f072fe66163aed8c0c8 Closes-Bug: #1500236
This commit is contained in:
parent
810176c7ad
commit
4ed9ef91e0
@ -186,8 +186,9 @@ class ClientTest(testtools.TestCase):
|
||||
'http://foo.com/trove/')
|
||||
|
||||
def test_log_req(self):
|
||||
self.logger = self.useFixture(
|
||||
logger = self.useFixture(
|
||||
fixtures.FakeLogger(
|
||||
name='troveclient.client',
|
||||
format="%(message)s",
|
||||
level=logging.DEBUG,
|
||||
nuke_handlers=True
|
||||
@ -207,7 +208,7 @@ class ClientTest(testtools.TestCase):
|
||||
'data': '{"auth": {"passwordCredentials": '
|
||||
'{"password": "password"}}}'})
|
||||
|
||||
output = self.logger.output.split('\n')
|
||||
output = logger.output.split('\n')
|
||||
|
||||
self.assertIn("REQ: curl -i /foo -X GET", output)
|
||||
self.assertIn(
|
||||
|
Loading…
Reference in New Issue
Block a user