Skip to content
Snippets Groups Projects
Commit 0c95a59c authored by David Douard's avatar David Douard
Browse files

tests: assertEquals -> assertEqual

to clear deprecation warnings.
parent b210fddf
No related branches found
No related tags found
No related merge requests found
......@@ -168,17 +168,17 @@ class ValidateCompound(unittest.TestCase):
exc = cm.exception
self.assertIsInstance(str(exc), str)
self.assertEquals(set(exc.error_dict.keys()), {NON_FIELD_ERRORS})
self.assertEqual(set(exc.error_dict.keys()), {NON_FIELD_ERRORS})
non_field_errors = exc.error_dict[NON_FIELD_ERRORS]
self.assertIsInstance(non_field_errors, list)
self.assertEquals(len(non_field_errors), 1)
self.assertEqual(len(non_field_errors), 1)
nested = non_field_errors[0]
self.assertIsInstance(nested, ValidationError)
self.assertEquals(nested.code, 'model-validation-failed')
self.assertEquals(nested.params['model'], self.test_model)
self.assertEquals(nested.params['validator'], 'validate_never')
self.assertEqual(nested.code, 'model-validation-failed')
self.assertEqual(nested.params['model'], self.test_model)
self.assertEqual(nested.params['validator'], 'validate_never')
def test_validate_against_schema_field_error(self):
with self.assertRaises(ValidationError) as cm:
......@@ -192,15 +192,15 @@ class ValidateCompound(unittest.TestCase):
exc = cm.exception
self.assertIsInstance(str(exc), str)
self.assertEquals(set(exc.error_dict.keys()), {'str'})
self.assertEqual(set(exc.error_dict.keys()), {'str'})
str_errors = exc.error_dict['str']
self.assertIsInstance(str_errors, list)
self.assertEquals(len(str_errors), 1)
self.assertEqual(len(str_errors), 1)
nested = str_errors[0]
self.assertIsInstance(nested, ValidationError)
self.assertEquals(nested.code, 'unexpected-type')
self.assertEqual(nested.code, 'unexpected-type')
def test_validate_against_schema_field_failed(self):
with self.assertRaises(ValidationError) as cm:
......@@ -215,14 +215,14 @@ class ValidateCompound(unittest.TestCase):
exc = cm.exception
self.assertIsInstance(str(exc), str)
self.assertEquals(set(exc.error_dict.keys()), {'int'})
self.assertEqual(set(exc.error_dict.keys()), {'int'})
int_errors = exc.error_dict['int']
self.assertIsInstance(int_errors, list)
self.assertEquals(len(int_errors), 1)
self.assertEqual(len(int_errors), 1)
nested = int_errors[0]
self.assertIsInstance(nested, ValidationError)
self.assertEquals(nested.code, 'field-validation-failed')
self.assertEquals(nested.params['validator'], 'validate_never')
self.assertEquals(nested.params['field'], 'int')
self.assertEqual(nested.code, 'field-validation-failed')
self.assertEqual(nested.params['validator'], 'validate_never')
self.assertEqual(nested.params['field'], 'int')
......@@ -107,7 +107,7 @@ class MultiHashTest(BaseHashutil):
hashes = MultiHash.from_path(f.name).digest()
os.remove(f.name)
self.assertEquals(self.checksums, hashes)
self.assertEqual(self.checksums, hashes)
class Hashutil(BaseHashutil):
......@@ -170,21 +170,21 @@ class Hashutil(BaseHashutil):
os.remove(f.name)
self.checksums['length'] = len(self.data)
self.assertEquals(self.checksums, hashes)
self.assertEqual(self.checksums, hashes)
def test_hash_to_hex(self):
for type in self.checksums:
hex = self.hex_checksums[type]
hash = self.checksums[type]
self.assertEquals(hashutil.hash_to_hex(hex), hex)
self.assertEquals(hashutil.hash_to_hex(hash), hex)
self.assertEqual(hashutil.hash_to_hex(hex), hex)
self.assertEqual(hashutil.hash_to_hex(hash), hex)
def test_hash_to_bytes(self):
for type in self.checksums:
hex = self.hex_checksums[type]
hash = self.checksums[type]
self.assertEquals(hashutil.hash_to_bytes(hex), hash)
self.assertEquals(hashutil.hash_to_bytes(hash), hash)
self.assertEqual(hashutil.hash_to_bytes(hex), hash)
self.assertEqual(hashutil.hash_to_bytes(hash), hash)
def test_hash_to_bytehex(self):
for algo in self.checksums:
......@@ -201,10 +201,10 @@ class Hashutil(BaseHashutil):
try:
hashutil._new_hash('blake2:10')
except ValueError as e:
self.assertEquals(str(e),
'Unexpected hashing algorithm blake2:10, '
'expected one of blake2b512, blake2s256, '
'sha1, sha1_git, sha256')
self.assertEqual(str(e),
'Unexpected hashing algorithm blake2:10, '
'expected one of blake2b512, blake2s256, '
'sha1, sha1_git, sha256')
@patch('hashlib.new')
def test_new_hash_blake2b_blake2b512_builtin(self, mock_hashlib_new):
......
......@@ -804,7 +804,7 @@ class SnapshotIdentifier(unittest.TestCase):
actual_value = identifiers.persistent_identifier(
full_type, _hash, metadata=_meta)
self.assertEquals(actual_value, expected_persistent_id)
self.assertEqual(actual_value, expected_persistent_id)
def test_persistent_identifier_wrong_input(self):
_snapshot_id = 'notahash4bc0bf3d81436bf980b46e98bd338453'
......@@ -839,7 +839,7 @@ class SnapshotIdentifier(unittest.TestCase):
metadata={}
)
actual_result = identifiers.parse_persistent_identifier(pid)
self.assertEquals(actual_result, expected_result)
self.assertEqual(actual_result, expected_result)
for pid, _type, _version, _hash, _metadata in [
('swh:1:cnt:9c95815d9e9d91b8dae8e05d8bbc696fe19f796b;lines=1-18;origin=https://github.com/python/cpython', # noqa
......@@ -862,7 +862,7 @@ class SnapshotIdentifier(unittest.TestCase):
metadata=_metadata
)
actual_result = identifiers.parse_persistent_identifier(pid)
self.assertEquals(actual_result, expected_result)
self.assertEqual(actual_result, expected_result)
def test_parse_persistent_identifier_parsing_error(self):
for pid, _error in [
......
......@@ -58,8 +58,8 @@ class TestValidators(unittest.TestCase):
exc = cm.exception
self.assertIsInstance(str(exc), str)
self.assertEquals(set(exc.error_dict.keys()),
{exceptions.NON_FIELD_ERRORS})
self.assertEqual(set(exc.error_dict.keys()),
{exceptions.NON_FIELD_ERRORS})
hash_mismatches = exc.error_dict[exceptions.NON_FIELD_ERRORS]
self.assertIsInstance(hash_mismatches, list)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment