Use testtools as base class for test cases.

Part of blueprint grizzly-testtools

Change-Id: Iff9aac184a115df9b396e218209962e6897a32d9
This commit is contained in:
Monty Taylor
2012-12-26 09:36:07 -06:00
parent f65f96bc59
commit e93d47a930
2 changed files with 15 additions and 8 deletions

View File

@@ -16,7 +16,7 @@
# TODO: More tests # TODO: More tests
import socket import socket
import StringIO import StringIO
import unittest import testtools
from urlparse import urlparse from urlparse import urlparse
# TODO: mock http connection class with more control over headers # TODO: mock http connection class with more control over headers
@@ -25,7 +25,7 @@ from utils import fake_http_connect, fake_get_keystoneclient_2_0
from swiftclient import client as c from swiftclient import client as c
class TestClientException(unittest.TestCase): class TestClientException(testtools.TestCase):
def test_is_exception(self): def test_is_exception(self):
self.assertTrue(issubclass(c.ClientException, Exception)) self.assertTrue(issubclass(c.ClientException, Exception))
@@ -51,7 +51,7 @@ class TestClientException(unittest.TestCase):
self.assertTrue(value in str(exc)) self.assertTrue(value in str(exc))
class TestJsonImport(unittest.TestCase): class TestJsonImport(testtools.TestCase):
def tearDown(self): def tearDown(self):
try: try:
@@ -67,6 +67,8 @@ class TestJsonImport(unittest.TestCase):
pass pass
else: else:
reload(simplejson) reload(simplejson)
super(TestJsonImport, self).tearDown()
def test_any(self): def test_any(self):
self.assertTrue(hasattr(c, 'json_loads')) self.assertTrue(hasattr(c, 'json_loads'))
@@ -91,9 +93,12 @@ class TestJsonImport(unittest.TestCase):
self.assertEquals(loads, c.json_loads) self.assertEquals(loads, c.json_loads)
class MockHttpTest(unittest.TestCase): class MockHttpTest(testtools.TestCase):
def setUp(self): def setUp(self):
super(MockHttpTest, self).setUp()
def fake_http_connection(*args, **kwargs): def fake_http_connection(*args, **kwargs):
_orig_http_connection = c.http_connection _orig_http_connection = c.http_connection
return_read = kwargs.get('return_read') return_read = kwargs.get('return_read')
@@ -119,6 +124,7 @@ class MockHttpTest(unittest.TestCase):
self.fake_http_connection = fake_http_connection self.fake_http_connection = fake_http_connection
def tearDown(self): def tearDown(self):
super(MockHttpTest, self).tearDown()
reload(c) reload(c)
@@ -695,4 +701,4 @@ class TestConnection(MockHttpTest):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() testtools.main()

View File

@@ -1,11 +1,12 @@
distribute>=0.6.24 distribute>=0.6.24
eventlet
nose nose
nose-exclude nose-exclude
nosehtmloutput
nosexcover nosexcover
openstack.nose_plugin openstack.nose_plugin
nosehtmloutput
pep8==1.3 pep8==1.3
sphinx>=1.1.2
eventlet
python-keystoneclient python-keystoneclient
sphinx>=1.1.2
testtools>=0.9.22