do not search file on real environment

Keystone cannot pass tox -epy27 on an environment which has
installed keystone service because we do not prevent oslo.config
searching all possible directories for configuration file, the
failed test is:

keystone.tests.unit.test_cli.CliNoConfigTestCase.test_cli

Unit test code should not rely on or be affected by real
environment, this patch mocks the oslo.config find_config_files to
empty as we expected, so it can succeed in every environment.

Change-Id: I0e8ade7414dbc92ca9334242c1369e0f51d2eba5
Closes-Bug: #1574493
This commit is contained in:
ZhiQiang Fan 2016-04-26 00:15:09 +08:00
parent 7be1edea7a
commit 2183b47af2
1 changed files with 2 additions and 0 deletions

View File

@ -52,6 +52,8 @@ class CliNoConfigTestCase(unit.BaseTestCase):
def setUp(self):
self.config_fixture = self.useFixture(config_fixture.Config(CONF))
self.config_fixture.register_cli_opt(cli.command_opt)
self.useFixture(mockpatch.Patch(
'oslo_config.cfg.find_config_files', return_value=[]))
super(CliNoConfigTestCase, self).setUp()
# NOTE(crinkle): the command call doesn't have to actually work,