1 Star 0 Fork 7

孟文华/apparmor

forked from src-openEuler/apparmor 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-0001-Replace-deprecated-assertEquals-with-assertEqual.patch 6.69 KB
一键复制 编辑 原始数据 按行查看 历史
From 2e2529bae81b0858d5f25c3d6f886fa3eba3f502 Mon Sep 17 00:00:00 2001
From: Christian Boltz <[email protected]>
Date: Tue, 26 Feb 2019 21:27:00 +0100
Subject: [PATCH] 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 <[email protected]>
---
.../swig/python/test/test_python.py.in | 4 ++--
parser/tst/caching.py | 24 +++++++++----------
utils/test/test-aa-easyprof.py | 4 ++--
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/libraries/libapparmor/swig/python/test/test_python.py.in b/libraries/libapparmor/swig/python/test/test_python.py.in
index 37849554..75c71415 100644
--- a/libraries/libapparmor/swig/python/test/test_python.py.in
+++ b/libraries/libapparmor/swig/python/test/test_python.py.in
@@ -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:
diff --git a/parser/tst/caching.py b/parser/tst/caching.py
index 6d07b696..ad8a1be0 100755
--- a/parser/tst/caching.py
+++ b/parser/tst/caching.py
@@ -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'''
diff --git a/utils/test/test-aa-easyprof.py b/utils/test/test-aa-easyprof.py
index ba468f3e..d2057972 100755
--- a/utils/test/test-aa-easyprof.py
+++ b/utils/test/test-aa-easyprof.py
@@ -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)'''
--
2.37.3.windows.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/meng-wenhua/apparmor.git
[email protected]:meng-wenhua/apparmor.git
meng-wenhua
apparmor
apparmor
master

搜索帮助