Browse Source

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
changes/24/128024/1
Eddie Sheffield 8 years ago
parent
commit
ee0c99c1f7
  1. 7
      glance/tests/stubs.py
  2. 7
      glance/tests/unit/test_manage.py

7
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

7
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)

Loading…
Cancel
Save