Replace deprecated assertEquals with assertEqual

assertEquals is deprecated since Python 2.7 and 3.2.
This commit is contained in:
Christian Boltz 2019-02-26 21:27:00 +01:00
parent 2ed3763a2f
commit 62abfe38e8
Failed to generate hash of commit
3 changed files with 16 additions and 16 deletions

View file

@ -74,7 +74,7 @@ class AAPythonBindingsTests(unittest.TestCase):
libapparmor.free_record(swig_record)
expected = self.parse_output_file(outfile)
self.assertEquals(expected, record,
self.assertEqual(expected, record,
"expected records did not match\n" +
"expected = %s\nactual = %s" % (expected, record))
@ -90,7 +90,7 @@ class AAPythonBindingsTests(unittest.TestCase):
line = l.rstrip('\n')
count += 1
if line == "START":
self.assertEquals(count, 1,
self.assertEqual(count, 1,
"Unexpected output format in %s" % (outfile))
continue
else:

View file

@ -137,7 +137,7 @@ class AAParserCachingCommon(testlib.AATestTemplate):
with open(features_path) as f:
features = f.read()
if expected:
self.assertEquals(expected_output, features,
self.assertEqual(expected_output, features,
"features contents differ, expected:\n%s\nresult:\n%s" % (expected_output, features))
else:
self.assertNotEquals(expected_output, features,
@ -269,7 +269,7 @@ class AAParserCachingTests(AAParserCachingCommon):
if (int(major) < 3) or ((int(major) == 3) and (int(minor) <= 2)):
self.assertAlmostEquals(time1, time2, places=5)
else:
self.assertEquals(time1, time2)
self.assertEqual(time1, time2)
def _set_mtime(self, path, mtime):
atime = os.stat(path).st_atime
@ -370,7 +370,7 @@ class AAParserCachingTests(AAParserCachingCommon):
# in cache_contents because of the difficulty coercing cache
# file bytes into strings in python3
self.assertNotEquals(orig_stat.st_size, stat.st_size, 'Expected cache file to be updated, size is not changed.')
self.assertEquals(os.stat(self.profile).st_mtime, stat.st_mtime)
self.assertEqual(os.stat(self.profile).st_mtime, stat.st_mtime)
def test_cache_writing_clears_all_files(self):
'''test cache writing clears all cache files'''
@ -388,7 +388,7 @@ class AAParserCachingTests(AAParserCachingCommon):
self._set_mtime(self.abstraction, 0)
self._set_mtime(self.profile, expected)
self._generate_cache_file()
self.assertEquals(expected, os.stat(self.cache_file).st_mtime)
self.assertEqual(expected, os.stat(self.cache_file).st_mtime)
def test_abstraction_mtime_preserved(self):
'''test abstraction mtime is preserved when it is newest'''
@ -396,7 +396,7 @@ class AAParserCachingTests(AAParserCachingCommon):
self._set_mtime(self.profile, 0)
self._set_mtime(self.abstraction, expected)
self._generate_cache_file()
self.assertEquals(expected, os.stat(self.cache_file).st_mtime)
self.assertEqual(expected, os.stat(self.cache_file).st_mtime)
def test_equal_mtimes_preserved(self):
'''test equal profile and abstraction mtimes are preserved'''
@ -404,7 +404,7 @@ class AAParserCachingTests(AAParserCachingCommon):
self._set_mtime(self.profile, expected)
self._set_mtime(self.abstraction, expected)
self._generate_cache_file()
self.assertEquals(expected, os.stat(self.cache_file).st_mtime)
self.assertEqual(expected, os.stat(self.cache_file).st_mtime)
def test_profile_newer_skips_cache(self):
'''test cache is skipped if profile is newer'''
@ -420,9 +420,9 @@ class AAParserCachingTests(AAParserCachingCommon):
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
stat = os.stat(self.cache_file)
self.assertEquals(orig_stat.st_size, stat.st_size)
self.assertEquals(orig_stat.st_ino, stat.st_ino)
self.assertEquals(orig_stat.st_mtime, stat.st_mtime)
self.assertEqual(orig_stat.st_size, stat.st_size)
self.assertEqual(orig_stat.st_ino, stat.st_ino)
self.assertEqual(orig_stat.st_mtime, stat.st_mtime)
def test_abstraction_newer_skips_cache(self):
'''test cache is skipped if abstraction is newer'''
@ -438,9 +438,9 @@ class AAParserCachingTests(AAParserCachingCommon):
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
stat = os.stat(self.cache_file)
self.assertEquals(orig_stat.st_size, stat.st_size)
self.assertEquals(orig_stat.st_ino, stat.st_ino)
self.assertEquals(orig_stat.st_mtime, stat.st_mtime)
self.assertEqual(orig_stat.st_size, stat.st_size)
self.assertEqual(orig_stat.st_ino, stat.st_ino)
self.assertEqual(orig_stat.st_mtime, stat.st_mtime)
def test_profile_newer_rewrites_cache(self):
'''test cache is rewritten if profile is newer'''

View file

@ -1674,7 +1674,7 @@ POLICYGROUPS_DIR="%s/templates"
# verify we get the same manifest back
man_new = easyp.gen_manifest(params)
self.assertEquals(m, man_new)
self.assertEqual(m, man_new)
def test_gen_manifest_ubuntu(self):
'''Test gen_manifest (ubuntu)'''
@ -1714,7 +1714,7 @@ POLICYGROUPS_DIR="%s/templates"
# verify we get the same manifest back
man_new = easyp.gen_manifest(params)
self.assertEquals(m, man_new)
self.assertEqual(m, man_new)
def test_parse_manifest_no_version(self):
'''Test parse_manifest (vendor with no version)'''