From 532ac9e1c7e883b0570a80e87d598a0ebf731e0b Mon Sep 17 00:00:00 2001 From: Kazuhiro MIYAHARA Date: Fri, 23 Feb 2018 07:24:12 +0000 Subject: [PATCH] Ensure reverting test env if the env is temporarily changed test_tempurl_keys_hidden_from_acl_readonly changes test env parameter temporarily for container HEAD. After that the test reverts the change. But if the HEAD failed with exception, the change is not reverted. With the non reverted change, some other tests fails even if the test have no problems. This patch ensures the reversion by using try-finally. Change-Id: I8cd7928da6211e5516992fe9f2bc8e568bcab443 --- test/functional/test_tempurl.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/functional/test_tempurl.py b/test/functional/test_tempurl.py index eb3c22d6f7..2e4be9021a 100644 --- a/test/functional/test_tempurl.py +++ b/test/functional/test_tempurl.py @@ -588,9 +588,12 @@ class TestContainerTempurl(Base): if not tf.cluster_info.get('tempauth'): raise SkipTest('TEMP AUTH SPECIFIC TEST') original_token = self.env.container.conn.storage_token - self.env.container.conn.storage_token = self.env.conn2.storage_token - metadata = self.env.container.info() - self.env.container.conn.storage_token = original_token + try: + self.env.container.conn.storage_token = \ + self.env.conn2.storage_token + metadata = self.env.container.info() + finally: + self.env.container.conn.storage_token = original_token self.assertNotIn( 'tempurl_key', metadata,