Skip to content

Commit

Permalink
Use assertEqual in place of deprecated assertEquals (#223)
Browse files Browse the repository at this point in the history
Fixes warnings of the form "DeprecationWarning: Please use assertEqual
instead." when running tests with warnings enabled.
  • Loading branch information
jdufresne authored and jschneier committed Oct 30, 2016
1 parent 66c9d6b commit c366cbf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions tests/test_s3boto.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ def setUp(self, S3Connection):
class SafeJoinTest(TestCase):
def test_normal(self):
path = s3boto.safe_join("", "path/to/somewhere", "other", "path/to/somewhere")
self.assertEquals(path, "path/to/somewhere/other/path/to/somewhere")
self.assertEqual(path, "path/to/somewhere/other/path/to/somewhere")

def test_with_dot(self):
path = s3boto.safe_join("", "path/./somewhere/../other", "..",
".", "to/./somewhere")
self.assertEquals(path, "path/to/somewhere")
self.assertEqual(path, "path/to/somewhere")

def test_base_url(self):
path = s3boto.safe_join("base_url", "path/to/somewhere")
self.assertEquals(path, "base_url/path/to/somewhere")
self.assertEqual(path, "base_url/path/to/somewhere")

def test_base_url_with_slash(self):
path = s3boto.safe_join("base_url/", "path/to/somewhere")
self.assertEquals(path, "base_url/path/to/somewhere")
self.assertEqual(path, "base_url/path/to/somewhere")

def test_suspicious_operation(self):
self.assertRaises(ValueError,
Expand All @@ -55,14 +55,14 @@ def test_trailing_slash(self):
Test safe_join with paths that end with a trailing slash.
"""
path = s3boto.safe_join("base_url/", "path/to/somewhere/")
self.assertEquals(path, "base_url/path/to/somewhere/")
self.assertEqual(path, "base_url/path/to/somewhere/")

def test_trailing_slash_multi(self):
"""
Test safe_join with multiple paths that end with a trailing slash.
"""
path = s3boto.safe_join("base_url/", "path/to/" "somewhere/")
self.assertEquals(path, "base_url/path/to/somewhere/")
self.assertEqual(path, "base_url/path/to/somewhere/")


class S3BotoStorageTests(S3BotoTestCase):
Expand Down Expand Up @@ -295,15 +295,15 @@ def test_storage_url(self):
response_headers=None,
)

self.assertEquals(self.storage.url(name), url)
self.assertEqual(self.storage.url(name), url)
self.storage.connection.generate_url.assert_called_with(
self.storage.querystring_expire,
**kwargs
)

custom_expire = 123

self.assertEquals(self.storage.url(name, expire=custom_expire), url)
self.assertEqual(self.storage.url(name, expire=custom_expire), url)
self.storage.connection.generate_url.assert_called_with(
custom_expire,
**kwargs
Expand Down
22 changes: 11 additions & 11 deletions tests/test_s3boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ def setUp(self, resource):
class SafeJoinTest(TestCase):
def test_normal(self):
path = s3boto3.safe_join("", "path/to/somewhere", "other", "path/to/somewhere")
self.assertEquals(path, "path/to/somewhere/other/path/to/somewhere")
self.assertEqual(path, "path/to/somewhere/other/path/to/somewhere")

def test_with_dot(self):
path = s3boto3.safe_join("", "path/./somewhere/../other", "..",
".", "to/./somewhere")
self.assertEquals(path, "path/to/somewhere")
self.assertEqual(path, "path/to/somewhere")

def test_base_url(self):
path = s3boto3.safe_join("base_url", "path/to/somewhere")
self.assertEquals(path, "base_url/path/to/somewhere")
self.assertEqual(path, "base_url/path/to/somewhere")

def test_base_url_with_slash(self):
path = s3boto3.safe_join("base_url/", "path/to/somewhere")
self.assertEquals(path, "base_url/path/to/somewhere")
self.assertEqual(path, "base_url/path/to/somewhere")

def test_suspicious_operation(self):
self.assertRaises(ValueError,
Expand All @@ -54,14 +54,14 @@ def test_trailing_slash(self):
Test safe_join with paths that end with a trailing slash.
"""
path = s3boto3.safe_join("base_url/", "path/to/somewhere/")
self.assertEquals(path, "base_url/path/to/somewhere/")
self.assertEqual(path, "base_url/path/to/somewhere/")

def test_trailing_slash_multi(self):
"""
Test safe_join with multiple paths that end with a trailing slash.
"""
path = s3boto3.safe_join("base_url/", "path/to/" "somewhere/")
self.assertEquals(path, "base_url/path/to/somewhere/")
self.assertEqual(path, "base_url/path/to/somewhere/")


class S3Boto3StorageTests(S3Boto3TestCase):
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_storage_save_gzip(self):
args, kwargs = obj.upload_fileobj.call_args
content = args[0]
zfile = gzip.GzipFile(mode='rb', fileobj=content)
self.assertEquals(zfile.read(), b"I should be gzip'd")
self.assertEqual(zfile.read(), b"I should be gzip'd")

def test_compress_content_len(self):
"""
Expand Down Expand Up @@ -293,7 +293,7 @@ def test_storage_url(self):
url = 'http://aws.amazon.com/%s' % name
self.storage.bucket.meta.client.generate_presigned_url.return_value = url
self.storage.bucket.name = 'bucket'
self.assertEquals(self.storage.url(name), url)
self.assertEqual(self.storage.url(name), url)
self.storage.bucket.meta.client.generate_presigned_url.assert_called_with(
'get_object',
Params={'Bucket': self.storage.bucket.name, 'Key': name},
Expand All @@ -302,7 +302,7 @@ def test_storage_url(self):

custom_expire = 123

self.assertEquals(self.storage.url(name, expire=custom_expire), url)
self.assertEqual(self.storage.url(name, expire=custom_expire), url)
self.storage.bucket.meta.client.generate_presigned_url.assert_called_with(
'get_object',
Params={'Bucket': self.storage.bucket.name, 'Key': name},
Expand All @@ -320,7 +320,7 @@ def test_generated_url_is_encoded(self):

def test_strip_signing_parameters(self):
expected = 'http://bucket.s3-aws-region.amazonaws.com/foo/bar'
self.assertEquals(self.storage._strip_signing_parameters(
self.assertEqual(self.storage._strip_signing_parameters(
'%s?X-Amz-Date=12345678&X-Amz-Signature=Signature' % expected), expected)
self.assertEquals(self.storage._strip_signing_parameters(
self.assertEqual(self.storage._strip_signing_parameters(
'%s?expires=12345678&signature=Signature' % expected), expected)

0 comments on commit c366cbf

Please sign in to comment.