From ee0c99c1f7b6451e22704539b6093b57109f7d4d Mon Sep 17 00:00:00 2001 From: Eddie Sheffield Date: Mon, 13 Oct 2014 13:14:46 -0400 Subject: [PATCH] Reduce extraneous test output The tests generate a large amount of extraneous logging output. This due to the manage utility, when tested via test_manage, setting up logging in it's own way. Monkey patching the log.setup call to a no-op during tests prevents this. Also fixed an incorrect usage of assert which was causing a warning to be generated. Change-Id: I6b8724142c0812d84e697e280acc0264620f6a2b --- glance/tests/stubs.py | 7 +++---- glance/tests/unit/test_manage.py | 7 +++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/glance/tests/stubs.py b/glance/tests/stubs.py index 01e330d744..957905140d 100644 --- a/glance/tests/stubs.py +++ b/glance/tests/stubs.py @@ -132,10 +132,9 @@ def stub_out_registry_and_store_server(stubs, base_dir, **kwargs): def endheaders(self): hl = [i.lower() for i in self.req.headers.keys()] - assert(not ('content-length' in hl and - 'transfer-encoding' in hl), - 'Content-Length and Transfer-Encoding ' - 'are mutually exclusive') + assert not ('content-length' in hl and + 'transfer-encoding' in hl), \ + 'Content-Length and Transfer-Encoding are mutually exclusive' def send(self, data): # send() is called during chunked-transfer encoding, and diff --git a/glance/tests/unit/test_manage.py b/glance/tests/unit/test_manage.py index 0e1f6299cf..73d1b40612 100644 --- a/glance/tests/unit/test_manage.py +++ b/glance/tests/unit/test_manage.py @@ -32,6 +32,7 @@ class TestManageBase(testtools.TestCase): def clear_conf(): manage.CONF.reset() manage.CONF.unregister_opt(manage.command_opt) + clear_conf() self.addCleanup(clear_conf) self.patcher = mock.patch('glance.db.sqlalchemy.api.get_engine') @@ -40,6 +41,12 @@ class TestManageBase(testtools.TestCase): def _main_test_helper(self, argv, func_name=None, *exp_args, **exp_kwargs): self.useFixture(fixtures.MonkeyPatch('sys.argv', argv)) + + def setup(product_name, version='unknown'): + pass + + self.useFixture(fixtures.MonkeyPatch( + 'glance.openstack.common.log.setup', setup)) manage.main() func_name.assert_called_once_with(*exp_args, **exp_kwargs)