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/object/v1/test_container.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'openstackclient/tests/functional/object') diff --git a/openstackclient/tests/functional/object/v1/test_container.py b/openstackclient/tests/functional/object/v1/test_container.py index af76efd9..acfbab11 100644 --- a/openstackclient/tests/functional/object/v1/test_container.py +++ b/openstackclient/tests/functional/object/v1/test_container.py @@ -21,14 +21,18 @@ class ContainerTests(base.TestCase): @classmethod def setUpClass(cls): + super(ContainerTests, cls).setUpClass() opts = cls.get_opts(['container']) raw_output = cls.openstack('container create ' + cls.NAME + opts) cls.assertOutput(cls.NAME + '\n', raw_output) @classmethod def tearDownClass(cls): - raw_output = cls.openstack('container delete ' + cls.NAME) - cls.assertOutput('', raw_output) + try: + raw_output = cls.openstack('container delete ' + cls.NAME) + cls.assertOutput('', raw_output) + finally: + super(ContainerTests, cls).tearDownClass() def test_container_list(self): opts = self.get_opts(['Name']) -- cgit v1.2.1