From 2a80f77c54f3f44c9a449a1a95647e19973251c6 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Wed, 11 Feb 2015 16:30:51 +1100 Subject: [PATCH] Shift EnvironmentVariable fixture setup to base While investigating a different branch, I came across a test failure due to the ROOT_DISK environment variable leaking into a test. The CMDEnvironmentTest already had code to deal with that case, added to deal with the same problem affecting it, so I moved the code into the base module so all tests can benefit. Change-Id: I7e82584f75a309c4cea6fb3f7c0c420358c778e1 --- os_cloud_config/cmd/utils/tests/test_environment.py | 8 -------- os_cloud_config/tests/base.py | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/os_cloud_config/cmd/utils/tests/test_environment.py b/os_cloud_config/cmd/utils/tests/test_environment.py index 317f669..b69e427 100644 --- a/os_cloud_config/cmd/utils/tests/test_environment.py +++ b/os_cloud_config/cmd/utils/tests/test_environment.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import fixtures import mock import testtools @@ -24,13 +23,6 @@ from os_cloud_config.tests import base class CMDEnviromentTest(base.TestCase): - def setUp(self): - super(CMDEnviromentTest, self).setUp() - for key in ('OS_AUTH_URL', 'OS_PASSWORD', 'OS_TENANT_NAME', - 'OS_USERNAME', 'OS_CACERT'): - fixture = fixtures.EnvironmentVariable(key) - self.useFixture(fixture) - @mock.patch.dict('os.environ', {}) def test_ensure_environment_missing_all(self): message = ("OS_AUTH_URL, OS_PASSWORD, OS_TENANT_NAME, OS_USERNAME " diff --git a/os_cloud_config/tests/base.py b/os_cloud_config/tests/base.py index 6e93268..f8e7060 100644 --- a/os_cloud_config/tests/base.py +++ b/os_cloud_config/tests/base.py @@ -51,3 +51,8 @@ class TestCase(testtools.TestCase): self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) self.log_fixture = self.useFixture(fixtures.FakeLogger()) + + for key in ('OS_AUTH_URL', 'OS_PASSWORD', 'OS_TENANT_NAME', + 'OS_USERNAME', 'OS_CACERT', 'ROOT_DISK'): + fixture = fixtures.EnvironmentVariable(key) + self.useFixture(fixture)