From f1d32dbe9b6f5f2e47853b9969483fa841e451f4 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Tue, 6 Jun 2017 21:03:33 +0800 Subject: 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 --- openstackclient/tests/functional/compute/v2/test_flavor.py | 8 ++++++-- openstackclient/tests/functional/compute/v2/test_server.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'openstackclient/tests/functional/compute/v2') diff --git a/openstackclient/tests/functional/compute/v2/test_flavor.py b/openstackclient/tests/functional/compute/v2/test_flavor.py index 0b01da51..eefd3fab 100644 --- a/openstackclient/tests/functional/compute/v2/test_flavor.py +++ b/openstackclient/tests/functional/compute/v2/test_flavor.py @@ -23,6 +23,7 @@ class FlavorTests(base.TestCase): @classmethod def setUpClass(cls): + super(FlavorTests, cls).setUpClass() # Make a project cmd_output = json.loads(cls.openstack( "project create -f json --enable " + cls.PROJECT_NAME @@ -31,8 +32,11 @@ class FlavorTests(base.TestCase): @classmethod def tearDownClass(cls): - raw_output = cls.openstack("project delete " + cls.PROJECT_NAME) - cls.assertOutput('', raw_output) + try: + raw_output = cls.openstack("project delete " + cls.PROJECT_NAME) + cls.assertOutput('', raw_output) + finally: + super(FlavorTests, cls).tearDownClass() def test_flavor_delete(self): """Test create w/project, delete multiple""" diff --git a/openstackclient/tests/functional/compute/v2/test_server.py b/openstackclient/tests/functional/compute/v2/test_server.py index c9f4d62c..b7a25996 100644 --- a/openstackclient/tests/functional/compute/v2/test_server.py +++ b/openstackclient/tests/functional/compute/v2/test_server.py @@ -25,6 +25,7 @@ class ServerTests(common.ComputeTestCase): @classmethod def setUpClass(cls): + super(ServerTests, cls).setUpClass() cls.haz_network = base.is_service_enabled('network') def test_server_list(self): -- cgit v1.2.1