diff options
| author | Rui Chen <chenrui.momo@gmail.com> | 2017-06-06 21:03:33 +0800 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2017-07-20 16:39:32 +0000 |
| commit | f1d32dbe9b6f5f2e47853b9969483fa841e451f4 (patch) | |
| tree | 1149b1d37c63a81caa58c9f6613f0726b9ddb3b5 /openstackclient/tests/functional/common | |
| parent | ac8cac4b63590e3b583faee88b6c481f2f3e9d9a (diff) | |
| download | python-openstackclient-f1d32dbe9b6f5f2e47853b9969483fa841e451f4.tar.gz | |
Clean up the changes of os.environ in functional tests
Use fixtures to restore the API version changes of os.environ
in each functional tests, aims to avoid the following test cases
failing in unexpected context.
And make sure setUpClass/tearDownClass call super class's
corresponding methods first.
Change-Id: Ie248fe9d3a9e25f1b076c9f2c363200f29a83817
Closes-Bug: #1696080
Diffstat (limited to 'openstackclient/tests/functional/common')
| -rw-r--r-- | openstackclient/tests/functional/common/test_extension.py | 1 | ||||
| -rw-r--r-- | openstackclient/tests/functional/common/test_help.py | 14 | ||||
| -rw-r--r-- | openstackclient/tests/functional/common/test_quota.py | 1 |
3 files changed, 9 insertions, 7 deletions
diff --git a/openstackclient/tests/functional/common/test_extension.py b/openstackclient/tests/functional/common/test_extension.py index d7dc398b..e3a91fe6 100644 --- a/openstackclient/tests/functional/common/test_extension.py +++ b/openstackclient/tests/functional/common/test_extension.py @@ -25,6 +25,7 @@ class ExtensionTests(base.TestCase): @classmethod def setUpClass(cls): + super(ExtensionTests, cls).setUpClass() cls.haz_network = base.is_service_enabled('network') def test_extension_list_compute(self): diff --git a/openstackclient/tests/functional/common/test_help.py b/openstackclient/tests/functional/common/test_help.py index e31d3b86..7f274099 100644 --- a/openstackclient/tests/functional/common/test_help.py +++ b/openstackclient/tests/functional/common/test_help.py @@ -12,6 +12,8 @@ import os +import fixtures + from openstackclient.tests.functional import base @@ -76,10 +78,11 @@ class HelpTests(base.TestCase): def test_commands_help_no_auth(self): """Check help commands without auth info.""" - # Pop all auth info - auth_info = {key: os.environ.pop(key) - for key in os.environ.keys() - if key.startswith('OS_')} + # Pop all auth info. os.environ will be changed in loop, so do not + # replace os.environ.keys() to os.environ + for key in os.environ.keys(): + if key.startswith('OS_'): + self.useFixture(fixtures.EnvironmentVariable(key, None)) raw_output = self.openstack('help') self.assertIn('usage: openstack', raw_output) @@ -115,6 +118,3 @@ class HelpTests(base.TestCase): self.assertIn('List containers', raw_output) raw_output = self.openstack('container list --help') self.assertIn('List containers', raw_output) - - # Restore auth info - os.environ.update(auth_info) diff --git a/openstackclient/tests/functional/common/test_quota.py b/openstackclient/tests/functional/common/test_quota.py index 1b13e95e..76c69a4d 100644 --- a/openstackclient/tests/functional/common/test_quota.py +++ b/openstackclient/tests/functional/common/test_quota.py @@ -26,6 +26,7 @@ class QuotaTests(base.TestCase): @classmethod def setUpClass(cls): + super(QuotaTests, cls).setUpClass() cls.haz_network = base.is_service_enabled('network') cls.PROJECT_NAME =\ cls.get_openstack_configuration_value('auth.project_name') |
