diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2012-12-27 11:50:53 -0600 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2013-01-15 15:59:59 -0600 |
| commit | fe3123b802cae77cf14d161cf6460a3264e6e4c2 (patch) | |
| tree | 7ef0a4fa1476e40ffc437dfea109020588ef36d9 /tests/test_shell.py | |
| parent | 541895994fe3cd51aa29e87030e537e0438fdf54 (diff) | |
| download | python-openstackclient-fe3123b802cae77cf14d161cf6460a3264e6e4c2.tar.gz | |
Move from unittest2 to testtools
Change-Id: I475a082af0660e0ee0e86ca4cd1bf0e2d711e3ed
Diffstat (limited to 'tests/test_shell.py')
| -rw-r--r-- | tests/test_shell.py | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/tests/test_shell.py b/tests/test_shell.py index 6410935a..e897fdfa 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -18,6 +18,7 @@ import os import mock +import fixtures from openstackclient import shell as os_shell from tests import utils @@ -50,18 +51,25 @@ def make_shell(): class ShellTest(utils.TestCase): + FAKE_ENV = { + 'OS_AUTH_URL': DEFAULT_AUTH_URL, + 'OS_TENANT_ID': DEFAULT_TENANT_ID, + 'OS_TENANT_NAME': DEFAULT_TENANT_NAME, + 'OS_USERNAME': DEFAULT_USERNAME, + 'OS_PASSWORD': DEFAULT_PASSWORD, + 'OS_REGION_NAME': DEFAULT_REGION_NAME, + } + def setUp(self): """ Patch os.environ to avoid required auth info""" - global _old_env - fake_env = { - 'OS_AUTH_URL': DEFAULT_AUTH_URL, - 'OS_TENANT_ID': DEFAULT_TENANT_ID, - 'OS_TENANT_NAME': DEFAULT_TENANT_NAME, - 'OS_USERNAME': DEFAULT_USERNAME, - 'OS_PASSWORD': DEFAULT_PASSWORD, - 'OS_REGION_NAME': DEFAULT_REGION_NAME, - } - _old_env, os.environ = os.environ, fake_env.copy() + super(ShellTest, self).setUp() + for var in self.FAKE_ENV: + self.useFixture( + fixtures.EnvironmentVariable( + var, + self.FAKE_ENV[var] + ) + ) # Make a fake shell object, a helping wrapper to call it, and a quick # way of asserting that certain API calls were made. @@ -77,10 +85,9 @@ class ShellTest(utils.TestCase): self.cmd_save = self.cmd_patch.start() def tearDown(self): - global _old_env - os.environ = _old_env #self.auth_patch.stop() self.cmd_patch.stop() + super(ShellTest, self).tearDown() def test_shell_args(self): sh = make_shell() |
