change assertEquals to assertEqual

According to http://docs.python.org/2/library/unittest.html
assertEquals is a deprecated alias of assertEqual.

Change-Id: I905d1bd9d3f1273c9724df6d6a36c53772e1a8ed
This commit is contained in:
Christian Berendt 2014-05-15 13:19:42 +02:00
parent 45dc9bddc5
commit 49c880435b
10 changed files with 217 additions and 217 deletions

View File

@ -34,7 +34,7 @@ class TestLimitingReader(test.TestCase):
for chunk in sizelimit.LimitingReader(data, BYTES):
bytes_read += len(chunk)
self.assertEquals(bytes_read, BYTES)
self.assertEqual(bytes_read, BYTES)
bytes_read = 0
data = StringIO.StringIO("*" * BYTES)
@ -44,7 +44,7 @@ class TestLimitingReader(test.TestCase):
bytes_read += 1
byte = reader.read(1)
self.assertEquals(bytes_read, BYTES)
self.assertEqual(bytes_read, BYTES)
def test_limiting_reader_fails(self):
BYTES = 1024

View File

@ -202,8 +202,8 @@ class TestGlanceImageService(test.TestCase):
image_id = self.service.create(self.context, fixture)['id']
self.assertNotEquals(None, image_id)
self.assertEquals(num_images + 1,
len(self.service.detail(self.context)))
self.assertEqual(num_images + 1,
len(self.service.detail(self.context)))
def test_create_and_show_non_existing_image(self):
fixture = self._make_fixture(name='test image')
@ -243,7 +243,7 @@ class TestGlanceImageService(test.TestCase):
ids.append(self.service.create(self.context, fixture)['id'])
image_metas = self.service.detail(self.context, marker=ids[1])
self.assertEquals(len(image_metas), 8)
self.assertEqual(len(image_metas), 8)
i = 2
for meta in image_metas:
expected = {
@ -277,7 +277,7 @@ class TestGlanceImageService(test.TestCase):
ids.append(self.service.create(self.context, fixture)['id'])
image_metas = self.service.detail(self.context, limit=5)
self.assertEquals(len(image_metas), 5)
self.assertEqual(len(image_metas), 5)
def test_detail_default_limit(self):
fixtures = []
@ -300,7 +300,7 @@ class TestGlanceImageService(test.TestCase):
ids.append(self.service.create(self.context, fixture)['id'])
image_metas = self.service.detail(self.context, marker=ids[3], limit=5)
self.assertEquals(len(image_metas), 5)
self.assertEqual(len(image_metas), 5)
i = 4
for meta in image_metas:
expected = {
@ -344,7 +344,7 @@ class TestGlanceImageService(test.TestCase):
self.service.update(self.context, image_id, fixture)
new_image_data = self.service.show(self.context, image_id)
self.assertEquals('new image name', new_image_data['name'])
self.assertEqual('new image name', new_image_data['name'])
def test_delete(self):
fixture1 = self._make_fixture(name='test image 1')
@ -352,7 +352,7 @@ class TestGlanceImageService(test.TestCase):
fixtures = [fixture1, fixture2]
num_images = len(self.service.detail(self.context))
self.assertEquals(0, num_images)
self.assertEqual(0, num_images)
ids = []
for fixture in fixtures:
@ -360,12 +360,12 @@ class TestGlanceImageService(test.TestCase):
ids.append(new_id)
num_images = len(self.service.detail(self.context))
self.assertEquals(2, num_images)
self.assertEqual(2, num_images)
self.service.delete(self.context, ids[0])
num_images = len(self.service.detail(self.context))
self.assertEquals(1, num_images)
self.assertEqual(1, num_images)
def test_show_passes_through_to_client(self):
fixture = self._make_fixture(name='image1', is_public=True)
@ -530,7 +530,7 @@ class TestGlanceImageService(test.TestCase):
image_id = self.service.create(self.context, fixture)['id']
(service, same_id) = glance.get_remote_image_service(self.context,
image_id)
self.assertEquals(same_id, image_id)
self.assertEqual(same_id, image_id)
def test_glance_client_image_ref(self):
fixture = self._make_fixture(name='test image')
@ -538,9 +538,9 @@ class TestGlanceImageService(test.TestCase):
image_url = 'http://something-less-likely/%s' % image_id
(service, same_id) = glance.get_remote_image_service(self.context,
image_url)
self.assertEquals(same_id, image_id)
self.assertEquals(service._client.host,
'something-less-likely')
self.assertEqual(same_id, image_id)
self.assertEqual(service._client.host,
'something-less-likely')
class TestGlanceClientVersion(test.TestCase):
@ -560,25 +560,25 @@ class TestGlanceClientVersion(test.TestCase):
"""Test glance version set by flag is honoured"""
client_wrapper_v1 = glance.GlanceClientWrapper('fake', 'fake_host',
9292)
self.assertEquals(client_wrapper_v1.client.__module__,
'glanceclient.v1.client')
self.assertEqual(client_wrapper_v1.client.__module__,
'glanceclient.v1.client')
self.flags(glance_api_version=2)
client_wrapper_v2 = glance.GlanceClientWrapper('fake', 'fake_host',
9292)
self.assertEquals(client_wrapper_v2.client.__module__,
'glanceclient.v2.client')
self.assertEqual(client_wrapper_v2.client.__module__,
'glanceclient.v2.client')
CONF.reset()
def test_glance_version_by_arg(self):
"""Test glance version set by arg to GlanceClientWrapper"""
client_wrapper_v1 = glance.GlanceClientWrapper('fake', 'fake_host',
9292, version=1)
self.assertEquals(client_wrapper_v1.client.__module__,
'glanceclient.v1.client')
self.assertEqual(client_wrapper_v1.client.__module__,
'glanceclient.v1.client')
client_wrapper_v2 = glance.GlanceClientWrapper('fake', 'fake_host',
9292, version=2)
self.assertEquals(client_wrapper_v2.client.__module__,
'glanceclient.v2.client')
self.assertEqual(client_wrapper_v2.client.__module__,
'glanceclient.v2.client')
def _create_failing_glance_client(info):

View File

@ -62,7 +62,7 @@ class SchedulerOptionsTestCase(test.TestCase):
fake = FakeSchedulerOptions(last_checked, now, file_old, file_now,
{}, jdata)
self.assertEquals({}, fake.get_configuration())
self.assertEqual({}, fake.get_configuration())
self.assertFalse(fake.file_was_loaded)
def test_get_configuration_first_time_empty_file(self):
@ -76,7 +76,7 @@ class SchedulerOptionsTestCase(test.TestCase):
fake = FakeSchedulerOptions(last_checked, now, file_old, file_now,
{}, jdata)
self.assertEquals({}, fake.get_configuration('foo.json'))
self.assertEqual({}, fake.get_configuration('foo.json'))
self.assertTrue(fake.file_was_loaded)
def test_get_configuration_first_time_happy_day(self):
@ -90,7 +90,7 @@ class SchedulerOptionsTestCase(test.TestCase):
fake = FakeSchedulerOptions(last_checked, now, file_old, file_now,
{}, jdata)
self.assertEquals(data, fake.get_configuration('foo.json'))
self.assertEqual(data, fake.get_configuration('foo.json'))
self.assertTrue(fake.file_was_loaded)
def test_get_configuration_second_time_no_change(self):
@ -104,7 +104,7 @@ class SchedulerOptionsTestCase(test.TestCase):
fake = FakeSchedulerOptions(last_checked, now, file_old, file_now,
data, jdata)
self.assertEquals(data, fake.get_configuration('foo.json'))
self.assertEqual(data, fake.get_configuration('foo.json'))
self.assertFalse(fake.file_was_loaded)
def test_get_configuration_second_time_too_fast(self):
@ -119,7 +119,7 @@ class SchedulerOptionsTestCase(test.TestCase):
fake = FakeSchedulerOptions(last_checked, now, file_old, file_now,
old_data, jdata)
self.assertEquals(old_data, fake.get_configuration('foo.json'))
self.assertEqual(old_data, fake.get_configuration('foo.json'))
self.assertFalse(fake.file_was_loaded)
def test_get_configuration_second_time_change(self):
@ -134,5 +134,5 @@ class SchedulerOptionsTestCase(test.TestCase):
fake = FakeSchedulerOptions(last_checked, now, file_old, file_now,
old_data, jdata)
self.assertEquals(data, fake.get_configuration('foo.json'))
self.assertEqual(data, fake.get_configuration('foo.json'))
self.assertTrue(fake.file_was_loaded)

View File

@ -24,22 +24,22 @@ class ContextTestCase(test.TestCase):
ctxt = context.RequestContext('111',
'222',
roles=['admin', 'weasel'])
self.assertEquals(ctxt.is_admin, True)
self.assertEqual(ctxt.is_admin, True)
def test_request_context_sets_is_admin_upcase(self):
ctxt = context.RequestContext('111',
'222',
roles=['Admin', 'weasel'])
self.assertEquals(ctxt.is_admin, True)
self.assertEqual(ctxt.is_admin, True)
def test_request_context_read_deleted(self):
ctxt = context.RequestContext('111',
'222',
read_deleted='yes')
self.assertEquals(ctxt.read_deleted, 'yes')
self.assertEqual(ctxt.read_deleted, 'yes')
ctxt.read_deleted = 'no'
self.assertEquals(ctxt.read_deleted, 'no')
self.assertEqual(ctxt.read_deleted, 'no')
def test_request_context_read_deleted_invalid(self):
self.assertRaises(ValueError,

View File

@ -56,10 +56,10 @@ class ManilaExceptionTestCase(test.TestCase):
message = "default message"
exc = FakeManilaException()
self.assertEquals(unicode(exc), 'default message')
self.assertEqual(unicode(exc), 'default message')
def test_error_msg(self):
self.assertEquals(unicode(exception.ManilaException('test')),
self.assertEqual(unicode(exception.ManilaException('test')),
'test')
def test_default_error_msg_with_kwargs(self):
@ -67,7 +67,7 @@ class ManilaExceptionTestCase(test.TestCase):
message = "default message: %(code)s"
exc = FakeManilaException(code=500)
self.assertEquals(unicode(exc), 'default message: 500')
self.assertEqual(unicode(exc), 'default message: 500')
def test_error_msg_exception_with_kwargs(self):
# NOTE(dprince): disable format errors for this test
@ -77,18 +77,18 @@ class ManilaExceptionTestCase(test.TestCase):
message = "default message: %(mispelled_code)s"
exc = FakeManilaException(code=500)
self.assertEquals(unicode(exc), 'default message: %(mispelled_code)s')
self.assertEqual(unicode(exc), 'default message: %(mispelled_code)s')
def test_default_error_code(self):
class FakeManilaException(exception.ManilaException):
code = 404
exc = FakeManilaException()
self.assertEquals(exc.kwargs['code'], 404)
self.assertEqual(exc.kwargs['code'], 404)
def test_error_code_from_kwarg(self):
class FakeManilaException(exception.ManilaException):
code = 500
exc = FakeManilaException(code=404)
self.assertEquals(exc.kwargs['code'], 404)
self.assertEqual(exc.kwargs['code'], 404)

View File

@ -204,7 +204,7 @@ class TestWSGIService(test.TestCase):
def test_service_random_port(self):
test_service = service.WSGIService("test_service")
self.assertEquals(0, test_service.port)
self.assertEqual(0, test_service.port)
test_service.start()
self.assertNotEqual(0, test_service.port)
test_service.stop()
@ -218,8 +218,8 @@ class TestLauncher(test.TestCase):
self.service = service.WSGIService("test_service")
def test_launch_app(self):
self.assertEquals(0, self.service.port)
self.assertEqual(0, self.service.port)
launcher = service.Launcher()
launcher.launch_server(self.service)
self.assertEquals(0, self.service.port)
self.assertEqual(0, self.service.port)
launcher.stop()

View File

@ -168,7 +168,7 @@ class ShareTestCase(test.TestCase):
share_id).id)
shr = db.share_get(self.context, share_id)
self.assertEquals(shr['status'], 'available')
self.assertEqual(shr['status'], 'available')
def test_create_delete_share_snapshot(self):
"""Test share's snapshot can be created and deleted."""
@ -191,7 +191,7 @@ class ShareTestCase(test.TestCase):
snapshot_id).share_id)
snap = db.share_snapshot_get(self.context, snapshot_id)
self.assertEquals(snap['status'], 'available')
self.assertEqual(snap['status'], 'available')
self.share.delete_snapshot(self.context, snapshot_id)
self.assertRaises(exception.NotFound,
@ -219,12 +219,12 @@ class ShareTestCase(test.TestCase):
self.context, share_id, snapshot_id)
snap = db.share_snapshot_get(self.context, snapshot_id)
self.assertEquals(snap['status'], 'error')
self.assertEqual(snap['status'], 'error')
self.assertRaises(exception.NotFound, self.share.delete_snapshot,
self.context, snapshot_id)
self.assertEquals('error_deleting', db.share_snapshot_get(
self.assertEqual('error_deleting', db.share_snapshot_get(
self.context, snapshot_id).status)
def test_delete_share_if_busy(self):
@ -242,7 +242,7 @@ class ShareTestCase(test.TestCase):
self.share.delete_snapshot(self.context, snapshot_id)
snap = db.share_snapshot_get(self.context, snapshot_id)
self.assertEquals(snap['status'], 'available')
self.assertEqual(snap['status'], 'available')
def test_create_delete_share(self):
"""Test share can be created and deleted."""
@ -255,7 +255,7 @@ class ShareTestCase(test.TestCase):
share_id).id)
shr = db.share_get(self.context, share_id)
self.assertEquals(shr['status'], 'available')
self.assertEqual(shr['status'], 'available')
self.share.delete_share(self.context, share_id)
self.assertRaises(exception.NotFound,
@ -284,14 +284,14 @@ class ShareTestCase(test.TestCase):
share_id)
shr = db.share_get(self.context, share_id)
self.assertEquals(shr['status'], 'error')
self.assertEqual(shr['status'], 'error')
self.assertRaises(exception.NotFound,
self.share.delete_share,
self.context,
share_id)
shr = db.share_get(self.context, share_id)
self.assertEquals(shr['status'], 'error_deleting')
self.assertEqual(shr['status'], 'error_deleting')
def test_allow_deny_access(self):
"""Test access rules to share can be created and deleted."""
@ -332,7 +332,7 @@ class ShareTestCase(test.TestCase):
access_id)
acs = db.share_access_get(self.context, access_id)
self.assertEquals(acs['state'], 'error')
self.assertEqual(acs['state'], 'error')
self.assertRaises(exception.NotFound,
self.share.deny_access,
@ -340,7 +340,7 @@ class ShareTestCase(test.TestCase):
access_id)
acs = db.share_access_get(self.context, access_id)
self.assertEquals(acs['state'], 'error')
self.assertEqual(acs['state'], 'error')
def test_create_delete_share_with_metadata(self):
"""Test share can be created with metadata and deleted."""

View File

@ -43,5 +43,5 @@ class ExampleSkipTestCase(test.TestCase):
ExampleSkipTestCase.test_counter += 1
def test_003_verify_test_counter(self):
self.assertEquals(ExampleSkipTestCase.test_counter, 2,
"Tests were not skipped appropriately")
self.assertEqual(ExampleSkipTestCase.test_counter, 2,
"Tests were not skipped appropriately")

View File

@ -79,8 +79,8 @@ exit 1
'always get passed '
'correctly')
runs = int(runs.strip())
self.assertEquals(runs, 10,
'Ran %d times instead of 10.' % (runs,))
self.assertEqual(runs, 10,
'Ran %d times instead of 10.' % (runs,))
finally:
os.unlink(tmpfilename)
os.unlink(tmpfilename2)
@ -126,104 +126,104 @@ class GetFromPathTestCase(test.TestCase):
f = utils.get_from_path
input = []
self.assertEquals([], f(input, "a"))
self.assertEquals([], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([], f(input, "a"))
self.assertEqual([], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [None]
self.assertEquals([], f(input, "a"))
self.assertEquals([], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([], f(input, "a"))
self.assertEqual([], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': None}]
self.assertEquals([], f(input, "a"))
self.assertEquals([], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([], f(input, "a"))
self.assertEqual([], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': {'b': None}}]
self.assertEquals([{'b': None}], f(input, "a"))
self.assertEquals([], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([{'b': None}], f(input, "a"))
self.assertEqual([], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': {'b': {'c': None}}}]
self.assertEquals([{'b': {'c': None}}], f(input, "a"))
self.assertEquals([{'c': None}], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([{'b': {'c': None}}], f(input, "a"))
self.assertEqual([{'c': None}], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': {'b': {'c': None}}}, {'a': None}]
self.assertEquals([{'b': {'c': None}}], f(input, "a"))
self.assertEquals([{'c': None}], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([{'b': {'c': None}}], f(input, "a"))
self.assertEqual([{'c': None}], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': {'b': {'c': None}}}, {'a': {'b': None}}]
self.assertEquals([{'b': {'c': None}}, {'b': None}], f(input, "a"))
self.assertEquals([{'c': None}], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([{'b': {'c': None}}, {'b': None}], f(input, "a"))
self.assertEqual([{'c': None}], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
def test_does_select(self):
f = utils.get_from_path
input = [{'a': 'a_1'}]
self.assertEquals(['a_1'], f(input, "a"))
self.assertEquals([], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual(['a_1'], f(input, "a"))
self.assertEqual([], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': {'b': 'b_1'}}]
self.assertEquals([{'b': 'b_1'}], f(input, "a"))
self.assertEquals(['b_1'], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([{'b': 'b_1'}], f(input, "a"))
self.assertEqual(['b_1'], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': {'b': {'c': 'c_1'}}}]
self.assertEquals([{'b': {'c': 'c_1'}}], f(input, "a"))
self.assertEquals([{'c': 'c_1'}], f(input, "a/b"))
self.assertEquals(['c_1'], f(input, "a/b/c"))
self.assertEqual([{'b': {'c': 'c_1'}}], f(input, "a"))
self.assertEqual([{'c': 'c_1'}], f(input, "a/b"))
self.assertEqual(['c_1'], f(input, "a/b/c"))
input = [{'a': {'b': {'c': 'c_1'}}}, {'a': None}]
self.assertEquals([{'b': {'c': 'c_1'}}], f(input, "a"))
self.assertEquals([{'c': 'c_1'}], f(input, "a/b"))
self.assertEquals(['c_1'], f(input, "a/b/c"))
self.assertEqual([{'b': {'c': 'c_1'}}], f(input, "a"))
self.assertEqual([{'c': 'c_1'}], f(input, "a/b"))
self.assertEqual(['c_1'], f(input, "a/b/c"))
input = [{'a': {'b': {'c': 'c_1'}}},
{'a': {'b': None}}]
self.assertEquals([{'b': {'c': 'c_1'}}, {'b': None}], f(input, "a"))
self.assertEquals([{'c': 'c_1'}], f(input, "a/b"))
self.assertEquals(['c_1'], f(input, "a/b/c"))
self.assertEqual([{'b': {'c': 'c_1'}}, {'b': None}], f(input, "a"))
self.assertEqual([{'c': 'c_1'}], f(input, "a/b"))
self.assertEqual(['c_1'], f(input, "a/b/c"))
input = [{'a': {'b': {'c': 'c_1'}}},
{'a': {'b': {'c': 'c_2'}}}]
self.assertEquals([{'b': {'c': 'c_1'}}, {'b': {'c': 'c_2'}}],
self.assertEqual([{'b': {'c': 'c_1'}}, {'b': {'c': 'c_2'}}],
f(input, "a"))
self.assertEquals([{'c': 'c_1'}, {'c': 'c_2'}], f(input, "a/b"))
self.assertEquals(['c_1', 'c_2'], f(input, "a/b/c"))
self.assertEqual([{'c': 'c_1'}, {'c': 'c_2'}], f(input, "a/b"))
self.assertEqual(['c_1', 'c_2'], f(input, "a/b/c"))
self.assertEquals([], f(input, "a/b/c/d"))
self.assertEquals([], f(input, "c/a/b/d"))
self.assertEquals([], f(input, "i/r/t"))
self.assertEqual([], f(input, "a/b/c/d"))
self.assertEqual([], f(input, "c/a/b/d"))
self.assertEqual([], f(input, "i/r/t"))
def test_flattens_lists(self):
f = utils.get_from_path
input = [{'a': [1, 2, 3]}]
self.assertEquals([1, 2, 3], f(input, "a"))
self.assertEquals([], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([1, 2, 3], f(input, "a"))
self.assertEqual([], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': {'b': [1, 2, 3]}}]
self.assertEquals([{'b': [1, 2, 3]}], f(input, "a"))
self.assertEquals([1, 2, 3], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([{'b': [1, 2, 3]}], f(input, "a"))
self.assertEqual([1, 2, 3], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': {'b': [1, 2, 3]}}, {'a': {'b': [4, 5, 6]}}]
self.assertEquals([1, 2, 3, 4, 5, 6], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([1, 2, 3, 4, 5, 6], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': [{'b': [1, 2, 3]}, {'b': [4, 5, 6]}]}]
self.assertEquals([1, 2, 3, 4, 5, 6], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([1, 2, 3, 4, 5, 6], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = [{'a': [1, 2, {'b': 'b_1'}]}]
self.assertEquals([1, 2, {'b': 'b_1'}], f(input, "a"))
self.assertEquals(['b_1'], f(input, "a/b"))
self.assertEqual([1, 2, {'b': 'b_1'}], f(input, "a"))
self.assertEqual(['b_1'], f(input, "a/b"))
def test_bad_xpath(self):
f = utils.get_from_path
@ -251,29 +251,29 @@ class GetFromPathTestCase(test.TestCase):
private_ips = f(inst, 'fixed_ip/address')
public_ips = f(inst, 'fixed_ip/floating_ips/address')
self.assertEquals(['192.168.0.3'], private_ips)
self.assertEquals(['1.2.3.4'], public_ips)
self.assertEqual(['192.168.0.3'], private_ips)
self.assertEqual(['1.2.3.4'], public_ips)
def test_accepts_dictionaries(self):
f = utils.get_from_path
input = {'a': [1, 2, 3]}
self.assertEquals([1, 2, 3], f(input, "a"))
self.assertEquals([], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([1, 2, 3], f(input, "a"))
self.assertEqual([], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = {'a': {'b': [1, 2, 3]}}
self.assertEquals([{'b': [1, 2, 3]}], f(input, "a"))
self.assertEquals([1, 2, 3], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([{'b': [1, 2, 3]}], f(input, "a"))
self.assertEqual([1, 2, 3], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = {'a': [{'b': [1, 2, 3]}, {'b': [4, 5, 6]}]}
self.assertEquals([1, 2, 3, 4, 5, 6], f(input, "a/b"))
self.assertEquals([], f(input, "a/b/c"))
self.assertEqual([1, 2, 3, 4, 5, 6], f(input, "a/b"))
self.assertEqual([], f(input, "a/b/c"))
input = {'a': [1, 2, {'b': 'b_1'}]}
self.assertEquals([1, 2, {'b': 'b_1'}], f(input, "a"))
self.assertEquals(['b_1'], f(input, "a/b"))
self.assertEqual([1, 2, {'b': 'b_1'}], f(input, "a"))
self.assertEqual(['b_1'], f(input, "a/b"))
class GenericUtilsTestCase(test.TestCase):
@ -454,7 +454,7 @@ class GenericUtilsTestCase(test.TestCase):
flo = StringIO.StringIO(data)
h1 = utils.hash_file(flo)
h2 = hashlib.sha1(data).hexdigest()
self.assertEquals(h1, h2)
self.assertEqual(h1, h2)
class MonkeyPatchTestCase(test.TestCase):
@ -524,126 +524,126 @@ class AuditPeriodTest(test.TestCase):
def test_hour(self):
begin, end = utils.last_completed_audit_period(unit='hour')
self.assertEquals(begin,
datetime.datetime(hour=7,
day=5,
month=3,
year=2012))
self.assertEquals(end, datetime.datetime(hour=8,
day=5,
month=3,
year=2012))
self.assertEqual(begin,
datetime.datetime(hour=7,
day=5,
month=3,
year=2012))
self.assertEqual(end, datetime.datetime(hour=8,
day=5,
month=3,
year=2012))
def test_hour_with_offset_before_current(self):
begin, end = utils.last_completed_audit_period(unit='hour@10')
self.assertEquals(begin, datetime.datetime(minute=10,
hour=7,
day=5,
month=3,
year=2012))
self.assertEquals(end, datetime.datetime(minute=10,
hour=8,
day=5,
month=3,
year=2012))
self.assertEqual(begin, datetime.datetime(minute=10,
hour=7,
day=5,
month=3,
year=2012))
self.assertEqual(end, datetime.datetime(minute=10,
hour=8,
day=5,
month=3,
year=2012))
def test_hour_with_offset_after_current(self):
begin, end = utils.last_completed_audit_period(unit='hour@30')
self.assertEquals(begin, datetime.datetime(minute=30,
hour=6,
day=5,
month=3,
year=2012))
self.assertEquals(end, datetime.datetime(minute=30,
hour=7,
day=5,
month=3,
year=2012))
self.assertEqual(begin, datetime.datetime(minute=30,
hour=6,
day=5,
month=3,
year=2012))
self.assertEqual(end, datetime.datetime(minute=30,
hour=7,
day=5,
month=3,
year=2012))
def test_day(self):
begin, end = utils.last_completed_audit_period(unit='day')
self.assertEquals(begin, datetime.datetime(day=4,
month=3,
year=2012))
self.assertEquals(end, datetime.datetime(day=5,
month=3,
year=2012))
self.assertEqual(begin, datetime.datetime(day=4,
month=3,
year=2012))
self.assertEqual(end, datetime.datetime(day=5,
month=3,
year=2012))
def test_day_with_offset_before_current(self):
begin, end = utils.last_completed_audit_period(unit='day@6')
self.assertEquals(begin, datetime.datetime(hour=6,
day=4,
month=3,
year=2012))
self.assertEquals(end, datetime.datetime(hour=6,
day=5,
month=3,
year=2012))
self.assertEqual(begin, datetime.datetime(hour=6,
day=4,
month=3,
year=2012))
self.assertEqual(end, datetime.datetime(hour=6,
day=5,
month=3,
year=2012))
def test_day_with_offset_after_current(self):
begin, end = utils.last_completed_audit_period(unit='day@10')
self.assertEquals(begin, datetime.datetime(hour=10,
day=3,
month=3,
year=2012))
self.assertEquals(end, datetime.datetime(hour=10,
day=4,
month=3,
year=2012))
self.assertEqual(begin, datetime.datetime(hour=10,
day=3,
month=3,
year=2012))
self.assertEqual(end, datetime.datetime(hour=10,
day=4,
month=3,
year=2012))
def test_month(self):
begin, end = utils.last_completed_audit_period(unit='month')
self.assertEquals(begin, datetime.datetime(day=1,
month=2,
year=2012))
self.assertEquals(end, datetime.datetime(day=1,
month=3,
year=2012))
self.assertEqual(begin, datetime.datetime(day=1,
month=2,
year=2012))
self.assertEqual(end, datetime.datetime(day=1,
month=3,
year=2012))
def test_month_with_offset_before_current(self):
begin, end = utils.last_completed_audit_period(unit='month@2')
self.assertEquals(begin, datetime.datetime(day=2,
month=2,
year=2012))
self.assertEquals(end, datetime.datetime(day=2,
month=3,
year=2012))
self.assertEqual(begin, datetime.datetime(day=2,
month=2,
year=2012))
self.assertEqual(end, datetime.datetime(day=2,
month=3,
year=2012))
def test_month_with_offset_after_current(self):
begin, end = utils.last_completed_audit_period(unit='month@15')
self.assertEquals(begin, datetime.datetime(day=15,
month=1,
year=2012))
self.assertEquals(end, datetime.datetime(day=15,
month=2,
year=2012))
self.assertEqual(begin, datetime.datetime(day=15,
month=1,
year=2012))
self.assertEqual(end, datetime.datetime(day=15,
month=2,
year=2012))
def test_year(self):
begin, end = utils.last_completed_audit_period(unit='year')
self.assertEquals(begin, datetime.datetime(day=1,
month=1,
year=2011))
self.assertEquals(end, datetime.datetime(day=1,
month=1,
year=2012))
self.assertEqual(begin, datetime.datetime(day=1,
month=1,
year=2011))
self.assertEqual(end, datetime.datetime(day=1,
month=1,
year=2012))
def test_year_with_offset_before_current(self):
begin, end = utils.last_completed_audit_period(unit='year@2')
self.assertEquals(begin, datetime.datetime(day=1,
month=2,
year=2011))
self.assertEquals(end, datetime.datetime(day=1,
month=2,
year=2012))
self.assertEqual(begin, datetime.datetime(day=1,
month=2,
year=2011))
self.assertEqual(end, datetime.datetime(day=1,
month=2,
year=2012))
def test_year_with_offset_after_current(self):
begin, end = utils.last_completed_audit_period(unit='year@6')
self.assertEquals(begin, datetime.datetime(day=1,
month=6,
year=2010))
self.assertEquals(end, datetime.datetime(day=1,
month=6,
year=2011))
self.assertEqual(begin, datetime.datetime(day=1,
month=6,
year=2010))
self.assertEqual(end, datetime.datetime(day=1,
month=6,
year=2011))
class FakeSSHClient(object):

View File

@ -71,7 +71,7 @@ document_root = /tmp
self.loader = manila.wsgi.Loader(self.config.name)
def test_config_found(self):
self.assertEquals(self.config.name, self.loader.config_path)
self.assertEqual(self.config.name, self.loader.config_path)
def test_app_not_found(self):
self.assertRaises(
@ -82,7 +82,7 @@ document_root = /tmp
def test_app_found(self):
url_parser = self.loader.load_app("test_app")
self.assertEquals("/tmp", url_parser.directory)
self.assertEqual("/tmp", url_parser.directory)
def tearDown(self):
self.config.close()
@ -102,7 +102,7 @@ class TestWSGIServer(unittest.TestCase):
def test_no_app(self):
server = manila.wsgi.Server("test_app", None)
self.assertEquals("test_app", server.name)
self.assertEqual("test_app", server.name)
def test_start_random_port(self):
server = manila.wsgi.Server("test_random_port", None, host="127.0.0.1")
@ -139,7 +139,7 @@ class TestWSGIServer(unittest.TestCase):
server.start()
response = urllib2.urlopen('http://127.0.0.1:%d/' % server.port)
self.assertEquals(greetings, response.read())
self.assertEqual(greetings, response.read())
server.stop()
@ -159,7 +159,7 @@ class TestWSGIServer(unittest.TestCase):
server.start()
response = urllib2.urlopen('https://127.0.0.1:%d/' % server.port)
self.assertEquals(greetings, response.read())
self.assertEqual(greetings, response.read())
server.stop()
@ -184,7 +184,7 @@ class TestWSGIServer(unittest.TestCase):
server.start()
response = urllib2.urlopen('https://[::1]:%d/' % server.port)
self.assertEquals(greetings, response.read())
self.assertEqual(greetings, response.read())
server.stop()
@ -230,7 +230,7 @@ class ExceptionTest(test.TestCase):
if hasattr(exception_type, 'headers'):
for (key, value) in exception_type.headers.iteritems():
self.assertTrue(key in resp.headers)
self.assertEquals(resp.headers[key], value)
self.assertEqual(resp.headers[key], value)
def test_quota_error_mapping(self):
self._do_test_exception_mapping(exception.QuotaError, 'too many used')