mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-28 21:07:56 +00:00
Replace deprecated assertEquals with assertEqual
assertEquals is deprecated since Python 2.7 and 3.2. (cherry picked from commit 62abfe38e8bb3e6ba4dc873efbd1855888ea8aa0) Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
df0ac742f7
commit
2e2529bae8
@ -74,7 +74,7 @@ class AAPythonBindingsTests(unittest.TestCase):
|
|||||||
libapparmor.free_record(swig_record)
|
libapparmor.free_record(swig_record)
|
||||||
|
|
||||||
expected = self.parse_output_file(outfile)
|
expected = self.parse_output_file(outfile)
|
||||||
self.assertEquals(expected, record,
|
self.assertEqual(expected, record,
|
||||||
"expected records did not match\n" +
|
"expected records did not match\n" +
|
||||||
"expected = %s\nactual = %s" % (expected, record))
|
"expected = %s\nactual = %s" % (expected, record))
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class AAPythonBindingsTests(unittest.TestCase):
|
|||||||
line = l.rstrip('\n')
|
line = l.rstrip('\n')
|
||||||
count += 1
|
count += 1
|
||||||
if line == "START":
|
if line == "START":
|
||||||
self.assertEquals(count, 1,
|
self.assertEqual(count, 1,
|
||||||
"Unexpected output format in %s" % (outfile))
|
"Unexpected output format in %s" % (outfile))
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
@ -137,7 +137,7 @@ class AAParserCachingCommon(testlib.AATestTemplate):
|
|||||||
with open(features_path) as f:
|
with open(features_path) as f:
|
||||||
features = f.read()
|
features = f.read()
|
||||||
if expected:
|
if expected:
|
||||||
self.assertEquals(expected_output, features,
|
self.assertEqual(expected_output, features,
|
||||||
"features contents differ, expected:\n%s\nresult:\n%s" % (expected_output, features))
|
"features contents differ, expected:\n%s\nresult:\n%s" % (expected_output, features))
|
||||||
else:
|
else:
|
||||||
self.assertNotEquals(expected_output, features,
|
self.assertNotEquals(expected_output, features,
|
||||||
@ -269,7 +269,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
|||||||
if (int(major) < 3) or ((int(major) == 3) and (int(minor) <= 2)):
|
if (int(major) < 3) or ((int(major) == 3) and (int(minor) <= 2)):
|
||||||
self.assertAlmostEquals(time1, time2, places=5)
|
self.assertAlmostEquals(time1, time2, places=5)
|
||||||
else:
|
else:
|
||||||
self.assertEquals(time1, time2)
|
self.assertEqual(time1, time2)
|
||||||
|
|
||||||
def _set_mtime(self, path, mtime):
|
def _set_mtime(self, path, mtime):
|
||||||
atime = os.stat(path).st_atime
|
atime = os.stat(path).st_atime
|
||||||
@ -370,7 +370,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
|||||||
# in cache_contents because of the difficulty coercing cache
|
# in cache_contents because of the difficulty coercing cache
|
||||||
# file bytes into strings in python3
|
# 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.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):
|
def test_cache_writing_clears_all_files(self):
|
||||||
'''test cache writing clears all cache files'''
|
'''test cache writing clears all cache files'''
|
||||||
@ -388,7 +388,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
|||||||
self._set_mtime(self.abstraction, 0)
|
self._set_mtime(self.abstraction, 0)
|
||||||
self._set_mtime(self.profile, expected)
|
self._set_mtime(self.profile, expected)
|
||||||
self._generate_cache_file()
|
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):
|
def test_abstraction_mtime_preserved(self):
|
||||||
'''test abstraction mtime is preserved when it is newest'''
|
'''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.profile, 0)
|
||||||
self._set_mtime(self.abstraction, expected)
|
self._set_mtime(self.abstraction, expected)
|
||||||
self._generate_cache_file()
|
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):
|
def test_equal_mtimes_preserved(self):
|
||||||
'''test equal profile and abstraction mtimes are preserved'''
|
'''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.profile, expected)
|
||||||
self._set_mtime(self.abstraction, expected)
|
self._set_mtime(self.abstraction, expected)
|
||||||
self._generate_cache_file()
|
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):
|
def test_profile_newer_skips_cache(self):
|
||||||
'''test cache is skipped if profile is newer'''
|
'''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')
|
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
|
||||||
|
|
||||||
stat = os.stat(self.cache_file)
|
stat = os.stat(self.cache_file)
|
||||||
self.assertEquals(orig_stat.st_size, stat.st_size)
|
self.assertEqual(orig_stat.st_size, stat.st_size)
|
||||||
self.assertEquals(orig_stat.st_ino, stat.st_ino)
|
self.assertEqual(orig_stat.st_ino, stat.st_ino)
|
||||||
self.assertEquals(orig_stat.st_mtime, stat.st_mtime)
|
self.assertEqual(orig_stat.st_mtime, stat.st_mtime)
|
||||||
|
|
||||||
def test_abstraction_newer_skips_cache(self):
|
def test_abstraction_newer_skips_cache(self):
|
||||||
'''test cache is skipped if abstraction is newer'''
|
'''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')
|
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
|
||||||
|
|
||||||
stat = os.stat(self.cache_file)
|
stat = os.stat(self.cache_file)
|
||||||
self.assertEquals(orig_stat.st_size, stat.st_size)
|
self.assertEqual(orig_stat.st_size, stat.st_size)
|
||||||
self.assertEquals(orig_stat.st_ino, stat.st_ino)
|
self.assertEqual(orig_stat.st_ino, stat.st_ino)
|
||||||
self.assertEquals(orig_stat.st_mtime, stat.st_mtime)
|
self.assertEqual(orig_stat.st_mtime, stat.st_mtime)
|
||||||
|
|
||||||
def test_profile_newer_rewrites_cache(self):
|
def test_profile_newer_rewrites_cache(self):
|
||||||
'''test cache is rewritten if profile is newer'''
|
'''test cache is rewritten if profile is newer'''
|
||||||
|
@ -1674,7 +1674,7 @@ POLICYGROUPS_DIR="%s/templates"
|
|||||||
|
|
||||||
# verify we get the same manifest back
|
# verify we get the same manifest back
|
||||||
man_new = easyp.gen_manifest(params)
|
man_new = easyp.gen_manifest(params)
|
||||||
self.assertEquals(m, man_new)
|
self.assertEqual(m, man_new)
|
||||||
|
|
||||||
def test_gen_manifest_ubuntu(self):
|
def test_gen_manifest_ubuntu(self):
|
||||||
'''Test gen_manifest (ubuntu)'''
|
'''Test gen_manifest (ubuntu)'''
|
||||||
@ -1714,7 +1714,7 @@ POLICYGROUPS_DIR="%s/templates"
|
|||||||
|
|
||||||
# verify we get the same manifest back
|
# verify we get the same manifest back
|
||||||
man_new = easyp.gen_manifest(params)
|
man_new = easyp.gen_manifest(params)
|
||||||
self.assertEquals(m, man_new)
|
self.assertEqual(m, man_new)
|
||||||
|
|
||||||
def test_parse_manifest_no_version(self):
|
def test_parse_manifest_no_version(self):
|
||||||
'''Test parse_manifest (vendor with no version)'''
|
'''Test parse_manifest (vendor with no version)'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user