Use testtools instead of unittest.

Part of blueprint grizzly-testtools

Change-Id: Ie914fd8f59cddb1a480566ec4eff908bfb51921c
This commit is contained in:
Monty Taylor
2012-12-24 22:37:01 -06:00
parent c057fe47d6
commit 1d461a6496
9 changed files with 24 additions and 20 deletions

View File

@@ -14,7 +14,7 @@
# under the License. # under the License.
import collections import collections
import unittest import testtools
from glanceclient import exc from glanceclient import exc
@@ -22,7 +22,7 @@ from glanceclient import exc
FakeResponse = collections.namedtuple('HTTPResponse', ['status']) FakeResponse = collections.namedtuple('HTTPResponse', ['status'])
class TestHTTPExceptions(unittest.TestCase): class TestHTTPExceptions(testtools.TestCase):
def test_from_response(self): def test_from_response(self):
"""exc.from_response should return instance of an HTTP exception""" """exc.from_response should return instance of an HTTP exception"""
out = exc.from_response(FakeResponse(400)) out = exc.from_response(FakeResponse(400))

View File

@@ -16,7 +16,7 @@
import httplib import httplib
import socket import socket
import StringIO import StringIO
import unittest import testtools
import mox import mox
@@ -25,7 +25,7 @@ from glanceclient.common import http
from tests import utils from tests import utils
class TestClient(unittest.TestCase): class TestClient(testtools.TestCase):
def test_connection_refused(self): def test_connection_refused(self):
""" """
Should receive a CommunicationError if connection refused. Should receive a CommunicationError if connection refused.
@@ -57,7 +57,7 @@ class TestClient(unittest.TestCase):
m.UnsetStubs() m.UnsetStubs()
class TestResponseBodyIterator(unittest.TestCase): class TestResponseBodyIterator(testtools.TestCase):
def test_iter_default_chunk_size_64k(self): def test_iter_default_chunk_size_64k(self):
resp = utils.FakeResponse({}, StringIO.StringIO('X' * 98304)) resp = utils.FakeResponse({}, StringIO.StringIO('X' * 98304))
iterator = http.ResponseBodyIterator(resp) iterator = http.ResponseBodyIterator(resp)

View File

@@ -14,7 +14,7 @@
# under the License. # under the License.
import os import os
import unittest import testtools
from OpenSSL import crypto from OpenSSL import crypto
@@ -26,7 +26,7 @@ TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
'var')) 'var'))
class TestVerifiedHTTPSConnection(unittest.TestCase): class TestVerifiedHTTPSConnection(testtools.TestCase):
def test_ssl_init_ok(self): def test_ssl_init_ok(self):
""" """
Test VerifiedHTTPSConnection class init Test VerifiedHTTPSConnection class init

View File

@@ -14,12 +14,12 @@
# under the License. # under the License.
import errno import errno
import unittest import testtools
from glanceclient.common import utils from glanceclient.common import utils
class TestUtils(unittest.TestCase): class TestUtils(testtools.TestCase):
def test_integrity_iter_without_checksum(self): def test_integrity_iter_without_checksum(self):
try: try:

View File

@@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import unittest import testtools
import glanceclient.v1.images import glanceclient.v1.images
import glanceclient.v1.image_members import glanceclient.v1.image_members
@@ -52,9 +52,10 @@ fixtures = {
} }
class ImageMemberManagerTest(unittest.TestCase): class ImageMemberManagerTest(testtools.TestCase):
def setUp(self): def setUp(self):
super(ImageMemberManagerTest, self).setUp()
self.api = utils.FakeAPI(fixtures) self.api = utils.FakeAPI(fixtures)
self.mgr = glanceclient.v1.image_members.ImageMemberManager(self.api) self.mgr = glanceclient.v1.image_members.ImageMemberManager(self.api)
self.image = glanceclient.v1.images.Image(self.api, {'id': '1'}, True) self.image = glanceclient.v1.images.Image(self.api, {'id': '1'}, True)

View File

@@ -16,7 +16,7 @@
import errno import errno
import json import json
import StringIO import StringIO
import unittest import testtools
import glanceclient.v1.images import glanceclient.v1.images
from tests import utils from tests import utils
@@ -239,9 +239,10 @@ fixtures = {
} }
class ImageManagerTest(unittest.TestCase): class ImageManagerTest(testtools.TestCase):
def setUp(self): def setUp(self):
super(ImageManagerTest, self).setUp()
self.api = utils.FakeAPI(fixtures) self.api = utils.FakeAPI(fixtures)
self.mgr = glanceclient.v1.images.ImageManager(self.api) self.mgr = glanceclient.v1.images.ImageManager(self.api)
@@ -448,8 +449,9 @@ class ImageManagerTest(unittest.TestCase):
self.assertEqual(self.api.calls, expect) self.assertEqual(self.api.calls, expect)
class ImageTest(unittest.TestCase): class ImageTest(testtools.TestCase):
def setUp(self): def setUp(self):
super(ImageTest, self).setUp()
self.api = utils.FakeAPI(fixtures) self.api = utils.FakeAPI(fixtures)
self.mgr = glanceclient.v1.images.ImageManager(self.api) self.mgr = glanceclient.v1.images.ImageManager(self.api)

View File

@@ -14,7 +14,7 @@
# under the License. # under the License.
import errno import errno
import unittest import testtools
import warlock import warlock
@@ -102,7 +102,7 @@ fake_schema = {'name': 'image', 'properties': {'id': {}, 'name': {}}}
FakeModel = warlock.model_factory(fake_schema) FakeModel = warlock.model_factory(fake_schema)
class TestController(unittest.TestCase): class TestController(testtools.TestCase):
def setUp(self): def setUp(self):
super(TestController, self).setUp() super(TestController, self).setUp()
self.api = utils.FakeAPI(fixtures) self.api = utils.FakeAPI(fixtures)

View File

@@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import unittest import testtools
from glanceclient.v2 import schemas from glanceclient.v2 import schemas
from tests import utils from tests import utils
@@ -43,7 +43,7 @@ fixtures = {
} }
class TestSchemaProperty(unittest.TestCase): class TestSchemaProperty(testtools.TestCase):
def test_property_minimum(self): def test_property_minimum(self):
prop = schemas.SchemaProperty('size') prop = schemas.SchemaProperty('size')
self.assertEqual(prop.name, 'size') self.assertEqual(prop.name, 'size')
@@ -54,7 +54,7 @@ class TestSchemaProperty(unittest.TestCase):
self.assertEqual(prop.description, 'some quantity') self.assertEqual(prop.description, 'some quantity')
class TestSchema(unittest.TestCase): class TestSchema(testtools.TestCase):
def test_schema_minimum(self): def test_schema_minimum(self):
raw_schema = {'name': 'Country', 'properties': {}} raw_schema = {'name': 'Country', 'properties': {}}
schema = schemas.Schema(raw_schema) schema = schemas.Schema(raw_schema)
@@ -73,7 +73,7 @@ class TestSchema(unittest.TestCase):
self.assertEqual(schema.raw(), raw_schema) self.assertEqual(schema.raw(), raw_schema)
class TestController(unittest.TestCase): class TestController(testtools.TestCase):
def setUp(self): def setUp(self):
super(TestController, self).setUp() super(TestController, self).setUp()
self.api = utils.FakeAPI(fixtures) self.api = utils.FakeAPI(fixtures)

View File

@@ -9,3 +9,4 @@ nosehtmloutput
pep8==1.3.3 pep8==1.3.3
setuptools-git>=0.4 setuptools-git>=0.4
sphinx>=1.1.2 sphinx>=1.1.2
testtools>=0.9.22