mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-04 16:25:10 +00:00
Change string formatting method in Python tests
This commit is contained in:
@@ -11,4 +11,4 @@ if tuple(map(int, setuptools.__version__.split("."))) >= (62, 1):
|
||||
identifier = sys.implementation.cache_tag
|
||||
else:
|
||||
identifier = "%d.%d" % sys.version_info[:2]
|
||||
print("lib.%s-%s" % (sysconfig.get_platform(), identifier))
|
||||
print("lib.{}-{}".format(sysconfig.get_platform(), identifier))
|
||||
|
@@ -64,8 +64,8 @@ class AAPythonBindingsTests(unittest.TestCase):
|
||||
self.maxDiff = None
|
||||
|
||||
def _runtest(self, testname):
|
||||
infile = "%s.in" % (testname)
|
||||
outfile = "%s.out" % (testname)
|
||||
infile = testname + ".in"
|
||||
outfile = testname + ".out"
|
||||
# infile *should* only contain one line
|
||||
with open(os.path.join(TESTDIR, infile), 'r') as f:
|
||||
line = f.read()
|
||||
@@ -78,7 +78,7 @@ class AAPythonBindingsTests(unittest.TestCase):
|
||||
expected = self.parse_output_file(outfile)
|
||||
self.assertEqual(expected, record,
|
||||
"expected records did not match\n"
|
||||
"expected = %s\nactual = %s" % (expected, record))
|
||||
"expected = {}\nactual = {}".format(expected, record))
|
||||
|
||||
def parse_output_file(self, outfile):
|
||||
"""parse testcase .out file and return dict"""
|
||||
@@ -93,7 +93,7 @@ class AAPythonBindingsTests(unittest.TestCase):
|
||||
count += 1
|
||||
if line == "START":
|
||||
self.assertEqual(count, 1,
|
||||
"Unexpected output format in %s" % (outfile))
|
||||
"Unexpected output format in " + outfile)
|
||||
continue
|
||||
else:
|
||||
key, value = line.split(": ", 1)
|
||||
@@ -141,8 +141,8 @@ def main():
|
||||
for f in find_testcases(TESTDIR):
|
||||
def stub_test(self, testname=f):
|
||||
self._runtest(testname)
|
||||
stub_test.__doc__ = "test %s" % (f)
|
||||
setattr(AAPythonBindingsTests, 'test_%s' % (f), stub_test)
|
||||
stub_test.__doc__ = "test " + f
|
||||
setattr(AAPythonBindingsTests, 'test_' + f, stub_test)
|
||||
return unittest.main(verbosity=2)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user