Move from unittest2 to testtools
Change-Id: I475a082af0660e0ee0e86ca4cd1bf0e2d711e3ed
This commit is contained in:
parent
541895994f
commit
fe3123b802
@ -18,6 +18,7 @@
|
|||||||
import os
|
import os
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
import fixtures
|
||||||
from openstackclient import shell as os_shell
|
from openstackclient import shell as os_shell
|
||||||
from tests import utils
|
from tests import utils
|
||||||
|
|
||||||
@ -50,10 +51,7 @@ def make_shell():
|
|||||||
|
|
||||||
class ShellTest(utils.TestCase):
|
class ShellTest(utils.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
FAKE_ENV = {
|
||||||
""" Patch os.environ to avoid required auth info"""
|
|
||||||
global _old_env
|
|
||||||
fake_env = {
|
|
||||||
'OS_AUTH_URL': DEFAULT_AUTH_URL,
|
'OS_AUTH_URL': DEFAULT_AUTH_URL,
|
||||||
'OS_TENANT_ID': DEFAULT_TENANT_ID,
|
'OS_TENANT_ID': DEFAULT_TENANT_ID,
|
||||||
'OS_TENANT_NAME': DEFAULT_TENANT_NAME,
|
'OS_TENANT_NAME': DEFAULT_TENANT_NAME,
|
||||||
@ -61,7 +59,17 @@ class ShellTest(utils.TestCase):
|
|||||||
'OS_PASSWORD': DEFAULT_PASSWORD,
|
'OS_PASSWORD': DEFAULT_PASSWORD,
|
||||||
'OS_REGION_NAME': DEFAULT_REGION_NAME,
|
'OS_REGION_NAME': DEFAULT_REGION_NAME,
|
||||||
}
|
}
|
||||||
_old_env, os.environ = os.environ, fake_env.copy()
|
|
||||||
|
def setUp(self):
|
||||||
|
""" Patch os.environ to avoid required auth info"""
|
||||||
|
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
|
# Make a fake shell object, a helping wrapper to call it, and a quick
|
||||||
# way of asserting that certain API calls were made.
|
# way of asserting that certain API calls were made.
|
||||||
@ -77,10 +85,9 @@ class ShellTest(utils.TestCase):
|
|||||||
self.cmd_save = self.cmd_patch.start()
|
self.cmd_save = self.cmd_patch.start()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
global _old_env
|
|
||||||
os.environ = _old_env
|
|
||||||
#self.auth_patch.stop()
|
#self.auth_patch.stop()
|
||||||
self.cmd_patch.stop()
|
self.cmd_patch.stop()
|
||||||
|
super(ShellTest, self).tearDown()
|
||||||
|
|
||||||
def test_shell_args(self):
|
def test_shell_args(self):
|
||||||
sh = make_shell()
|
sh = make_shell()
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
import mox
|
import mox
|
||||||
import unittest2
|
import testtools
|
||||||
|
|
||||||
|
|
||||||
class TestCase(unittest2.TestCase):
|
class TestCase(testtools.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestCase, self).setUp()
|
super(TestCase, self).setUp()
|
||||||
@ -16,6 +16,6 @@ class TestCase(unittest2.TestCase):
|
|||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
time.time = self._original_time
|
time.time = self._original_time
|
||||||
super(TestCase, self).tearDown()
|
|
||||||
self.mox.UnsetStubs()
|
self.mox.UnsetStubs()
|
||||||
self.mox.VerifyAll()
|
self.mox.VerifyAll()
|
||||||
|
super(TestCase, self).tearDown()
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
distribute>=0.6.24
|
distribute>=0.6.24
|
||||||
|
|
||||||
coverage
|
coverage
|
||||||
|
fixtures
|
||||||
mock
|
mock
|
||||||
mox
|
mox
|
||||||
nose
|
nose
|
||||||
nose-exclude
|
nose-exclude
|
||||||
|
nosehtmloutput
|
||||||
nosexcover
|
nosexcover
|
||||||
openstack.nose_plugin
|
openstack.nose_plugin
|
||||||
nosehtmloutput
|
|
||||||
pep8==0.6.1
|
pep8==0.6.1
|
||||||
sphinx>=1.1.2
|
sphinx>=1.1.2
|
||||||
unittest2
|
testtools>=0.9.22
|
||||||
|
Loading…
x
Reference in New Issue
Block a user