change deprecated assertEquals to assertEqual

fix against H234: assertEquals() logs a DeprecationWarning
in Python3.x. use assertEqual() instead.

Closes-bug: #1480776

Change-Id: Iffda6bb5f2616d4af4567eeea37bb26531e34371
Signed-off-by: Hiroshi Miura <miurahr@nttdata.co.jp>
This commit is contained in:
Hiroshi Miura 2015-08-03 12:20:44 +09:00
parent a056f1b374
commit be0f1aad8a
5 changed files with 52 additions and 51 deletions

@ -88,7 +88,7 @@ class TestConnectionThreadPoolExecutor(ThreadTestCase):
f.result()
except Exception as e:
went_boom = True
self.assertEquals('I went boom!', str(e))
self.assertEqual('I went boom!', str(e))
self.assertTrue(went_boom)
# Has the connection been returned to the pool?
@ -112,7 +112,7 @@ class TestConnectionThreadPoolExecutor(ThreadTestCase):
f.result()
except Exception as e:
connection_failed = True
self.assertEquals('This is a failed connection', str(e))
self.assertEqual('This is a failed connection', str(e))
self.assertTrue(connection_failed)
# Make sure we don't lock up on failed connections
@ -122,7 +122,7 @@ class TestConnectionThreadPoolExecutor(ThreadTestCase):
f.result()
except Exception as e:
connection_failed = True
self.assertEquals('This is a failed connection', str(e))
self.assertEqual('This is a failed connection', str(e))
self.assertTrue(connection_failed)
def test_lazy_connections(self):

@ -138,7 +138,7 @@ class TestShell(unittest.TestCase):
with CaptureOutput() as output:
swiftclient.shell.main(argv)
self.assertEquals(output.out,
self.assertEqual(output.out,
' Account: AUTH_account\n'
'Containers: 1\n'
' Objects: 2\n'
@ -160,7 +160,7 @@ class TestShell(unittest.TestCase):
with CaptureOutput() as output:
swiftclient.shell.main(argv)
self.assertEquals(output.out,
self.assertEqual(output.out,
' Account: AUTH_account\n'
'Container: container\n'
' Objects: 1\n'
@ -186,7 +186,7 @@ class TestShell(unittest.TestCase):
with CaptureOutput() as output:
swiftclient.shell.main(argv)
self.assertEquals(output.out,
self.assertEqual(output.out,
' Account: AUTH_account\n'
' Container: container\n'
' Object: object\n'
@ -212,7 +212,7 @@ class TestShell(unittest.TestCase):
mock.call(marker='container', prefix=None)]
connection.return_value.get_account.assert_has_calls(calls)
self.assertEquals(output.out, 'container\n')
self.assertEqual(output.out, 'container\n')
@mock.patch('swiftclient.service.Connection')
def test_list_account_long(self, connection):
@ -229,7 +229,7 @@ class TestShell(unittest.TestCase):
mock.call(marker='container', prefix=None)]
connection.return_value.get_account.assert_has_calls(calls)
self.assertEquals(output.out,
self.assertEqual(output.out,
' 0 0 1970-01-01 00:00:01 container\n'
' 0 0\n')
@ -249,7 +249,7 @@ class TestShell(unittest.TestCase):
mock.call(marker='container', prefix=None)]
connection.return_value.get_account.assert_has_calls(calls)
self.assertEquals(output.out,
self.assertEqual(output.out,
' 0 0 ????-??-?? ??:??:?? container\n'
' 0 0\n')
@ -294,7 +294,7 @@ class TestShell(unittest.TestCase):
delimiter=None, prefix=None)]
connection.return_value.get_container.assert_has_calls(calls)
self.assertEquals(output.out, 'object_a\n')
self.assertEqual(output.out, 'object_a\n')
# Test container listing with --long
connection.return_value.get_container.side_effect = [
@ -311,7 +311,7 @@ class TestShell(unittest.TestCase):
delimiter=None, prefix=None)]
connection.return_value.get_container.assert_has_calls(calls)
self.assertEquals(output.out,
self.assertEqual(output.out,
' 0 123 456 object_a\n'
' 0\n')
@ -771,7 +771,7 @@ class TestShell(unittest.TestCase):
with ExpectedException(SystemExit):
swiftclient.shell.main(argv)
self.assertEquals(output.err, 'bad auth\n')
self.assertEqual(output.err, 'bad auth\n')
@mock.patch('swiftclient.service.Connection')
def test_post_account_not_found(self, connection):
@ -783,7 +783,7 @@ class TestShell(unittest.TestCase):
with ExpectedException(SystemExit):
swiftclient.shell.main(argv)
self.assertEquals(output.err, 'Account not found\n')
self.assertEqual(output.err, 'Account not found\n')
@mock.patch('swiftclient.service.Connection')
def test_post_container(self, connection):
@ -802,7 +802,7 @@ class TestShell(unittest.TestCase):
with ExpectedException(SystemExit):
swiftclient.shell.main(argv)
self.assertEquals(output.err, 'bad auth\n')
self.assertEqual(output.err, 'bad auth\n')
@mock.patch('swiftclient.service.Connection')
def test_post_container_not_found_causes_put(self, connection):
@ -860,7 +860,7 @@ class TestShell(unittest.TestCase):
with ExpectedException(SystemExit):
swiftclient.shell.main(argv)
self.assertEquals(output.err, 'bad auth\n')
self.assertEqual(output.err, 'bad auth\n')
def test_post_object_too_many_args(self):
argv = ["", "post", "container", "object", "bad_arg"]
@ -925,41 +925,41 @@ class TestShell(unittest.TestCase):
# Test invalid states
argv = ["", "upload", "-S", "1234X", "container", "object"]
swiftclient.shell.main(argv)
self.assertEquals(output.err, "Invalid segment size\n")
self.assertEqual(output.err, "Invalid segment size\n")
output.clear()
with ExpectedException(SystemExit):
argv = ["", "upload", "-S", "K1234", "container", "object"]
swiftclient.shell.main(argv)
self.assertEquals(output.err, "Invalid segment size\n")
self.assertEqual(output.err, "Invalid segment size\n")
output.clear()
with ExpectedException(SystemExit):
argv = ["", "upload", "-S", "K", "container", "object"]
swiftclient.shell.main(argv)
self.assertEquals(output.err, "Invalid segment size\n")
self.assertEqual(output.err, "Invalid segment size\n")
def test_negative_upload_segment_size(self):
with CaptureOutput() as output:
with ExpectedException(SystemExit):
argv = ["", "upload", "-S", "-40", "container", "object"]
swiftclient.shell.main(argv)
self.assertEquals(output.err, "segment-size should be positive\n")
self.assertEqual(output.err, "segment-size should be positive\n")
output.clear()
with ExpectedException(SystemExit):
argv = ["", "upload", "-S", "-40K", "container", "object"]
swiftclient.shell.main(argv)
self.assertEquals(output.err, "segment-size should be positive\n")
self.assertEqual(output.err, "segment-size should be positive\n")
output.clear()
with ExpectedException(SystemExit):
argv = ["", "upload", "-S", "-40M", "container", "object"]
swiftclient.shell.main(argv)
self.assertEquals(output.err, "segment-size should be positive\n")
self.assertEqual(output.err, "segment-size should be positive\n")
output.clear()
with ExpectedException(SystemExit):
argv = ["", "upload", "-S", "-40G", "container", "object"]
swiftclient.shell.main(argv)
self.assertEquals(output.err, "segment-size should be positive\n")
self.assertEqual(output.err, "segment-size should be positive\n")
output.clear()
@ -1625,7 +1625,7 @@ class TestAuth(MockHttpTest):
export OS_STORAGE_URL=https://swift.storage.example.com/v1/AUTH_test
export OS_AUTH_TOKEN=AUTH_tk5b6b12
"""
self.assertEquals(textwrap.dedent(expected).lstrip(),
self.assertEqual(textwrap.dedent(expected).lstrip(),
stdout.getvalue())
def test_auth_verbose(self):
@ -1646,7 +1646,7 @@ class TestAuth(MockHttpTest):
export ST_USER=test:tester
export ST_KEY='te$tin&'
"""
self.assertEquals(textwrap.dedent(expected).lstrip(),
self.assertEqual(textwrap.dedent(expected).lstrip(),
stdout.getvalue())
self.assertEqual([], mock_conn.mock_calls)
@ -1669,7 +1669,7 @@ class TestAuth(MockHttpTest):
export OS_STORAGE_URL=http://url/
export OS_AUTH_TOKEN=token
"""
self.assertEquals(textwrap.dedent(expected).lstrip(),
self.assertEqual(textwrap.dedent(expected).lstrip(),
stdout.getvalue())
def test_auth_verbose_v2(self):
@ -1695,7 +1695,7 @@ class TestAuth(MockHttpTest):
export OS_TENANT_NAME=demo
export OS_USERNAME=demo
"""
self.assertEquals(textwrap.dedent(expected).lstrip(),
self.assertEqual(textwrap.dedent(expected).lstrip(),
stdout.getvalue())
self.assertEqual([], mock_keystone.mock_calls)

@ -693,9 +693,9 @@ class TestGetObject(MockHttpTest):
c.http_connection = self.fake_http_connection(200, body='abcde')
__, resp = conn.get_object('asdf', 'asdf', resp_chunk_size=3)
self.assertTrue(hasattr(resp, 'read'))
self.assertEquals(resp.read(3), 'abc')
self.assertEquals(resp.read(None), 'de')
self.assertEquals(resp.read(), '')
self.assertEqual(resp.read(3), 'abc')
self.assertEqual(resp.read(None), 'de')
self.assertEqual(resp.read(), '')
def test_chunk_size_iter(self):
conn = c.Connection('http://auth.url/', 'some_user', 'some_key')
@ -704,8 +704,8 @@ class TestGetObject(MockHttpTest):
c.http_connection = self.fake_http_connection(200, body='abcde')
__, resp = conn.get_object('asdf', 'asdf', resp_chunk_size=3)
self.assertTrue(hasattr(resp, 'next'))
self.assertEquals(next(resp), 'abc')
self.assertEquals(next(resp), 'de')
self.assertEqual(next(resp), 'abc')
self.assertEqual(next(resp), 'de')
self.assertRaises(StopIteration, next, resp)
def test_chunk_size_read_and_iter(self):
@ -715,11 +715,11 @@ class TestGetObject(MockHttpTest):
c.http_connection = self.fake_http_connection(200, body='abcdef')
__, resp = conn.get_object('asdf', 'asdf', resp_chunk_size=2)
self.assertTrue(hasattr(resp, 'read'))
self.assertEquals(resp.read(3), 'abc')
self.assertEquals(next(resp), 'de')
self.assertEquals(resp.read(), 'f')
self.assertEqual(resp.read(3), 'abc')
self.assertEqual(next(resp), 'de')
self.assertEqual(resp.read(), 'f')
self.assertRaises(StopIteration, next, resp)
self.assertEquals(resp.read(), '')
self.assertEqual(resp.read(), '')
class TestHeadObject(MockHttpTest):
@ -871,9 +871,9 @@ class TestPutObject(MockHttpTest):
contents=contents,
chunk_size=chunk_size)
self.assertNotEquals(etag, contents.get_md5sum())
self.assertEquals(etag, 'badresponseetag')
self.assertEquals(raw_data_md5, contents.get_md5sum())
self.assertNotEqual(etag, contents.get_md5sum())
self.assertEqual(etag, 'badresponseetag')
self.assertEqual(raw_data_md5, contents.get_md5sum())
def test_md5_match(self):
conn = c.http_connection('http://www.test.com')
@ -896,8 +896,8 @@ class TestPutObject(MockHttpTest):
contents=contents,
chunk_size=chunk_size)
self.assertEquals(raw_data_md5, contents.get_md5sum())
self.assertEquals(etag, contents.get_md5sum())
self.assertEqual(raw_data_md5, contents.get_md5sum())
self.assertEqual(etag, contents.get_md5sum())
def test_params(self):
conn = c.http_connection(u'http://www.test.com/')

@ -176,19 +176,19 @@ class TestReadableToIterable(testtools.TestCase):
data = u.ReadableToIterable(f, chunk_size, True)
for i, data_chunk in enumerate(data):
self.assertEquals(chunk_size, len(data_chunk))
self.assertEquals(data_chunk, write_data[i] * chunk_size)
self.assertEqual(chunk_size, len(data_chunk))
self.assertEqual(data_chunk, write_data[i] * chunk_size)
self.assertEquals(actual_md5sum.hexdigest(), data.get_md5sum())
self.assertEqual(actual_md5sum.hexdigest(), data.get_md5sum())
def test_md5_creation(self):
# Check creation with a real and noop md5 class
data = u.ReadableToIterable(None, None, md5=True)
self.assertEquals(md5().hexdigest(), data.get_md5sum())
self.assertEqual(md5().hexdigest(), data.get_md5sum())
self.assertTrue(isinstance(data.md5sum, type(md5())))
data = u.ReadableToIterable(None, None, md5=False)
self.assertEquals('', data.get_md5sum())
self.assertEqual('', data.get_md5sum())
self.assertTrue(isinstance(data.md5sum, type(u.NoopMD5())))
def test_unicode(self):
@ -203,14 +203,14 @@ class TestReadableToIterable(testtools.TestCase):
data = u.ReadableToIterable(f, chunk_size, True)
x = next(data)
self.assertEquals(2, len(x))
self.assertEquals(unicode_data[:2], x)
self.assertEqual(2, len(x))
self.assertEqual(unicode_data[:2], x)
x = next(data)
self.assertEquals(1, len(x))
self.assertEquals(unicode_data[2:], x)
self.assertEqual(1, len(x))
self.assertEqual(unicode_data[2:], x)
self.assertEquals(actual_md5sum, data.get_md5sum())
self.assertEqual(actual_md5sum, data.get_md5sum())
class TestLengthWrapper(testtools.TestCase):

@ -45,10 +45,11 @@ commands=
# H102 -> apache2 license exists
# H103 -> license is apache
# H201 -> no bare excepts
# H234 -> assertEquals is deprecated, use assertEqual
# H238 -> old style classes are deprecated and not available in python3
# H501 -> don't use locals() for str formatting
# H903 -> \n not \r\n
ignore = H
select = H102, H103, H201, H238, H501, H903
select = H102, H103, H201, H234, H238, H501, H903
show-source = True
exclude = .venv,.tox,dist,doc,*egg