aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/report_tests/encryption_tests.py6
-rw-r--r--tests/report_tests/help_output_tests.py2
-rw-r--r--tests/report_tests/plugin_tests/networking/networking.py2
-rw-r--r--tests/report_tests/smoke_tests.py4
-rw-r--r--tests/sos_tests.py38
-rw-r--r--tests/unittests/conformance_tests.py10
6 files changed, 31 insertions, 31 deletions
diff --git a/tests/report_tests/encryption_tests.py b/tests/report_tests/encryption_tests.py
index 64b01fde..c18398a8 100644
--- a/tests/report_tests/encryption_tests.py
+++ b/tests/report_tests/encryption_tests.py
@@ -19,11 +19,11 @@ class EncryptedReportTest(StageOneReportTest):
"""
encrypt_pass = 'sostest'
- sos_cmd = "-o kernel --encrypt-pass %s" % encrypt_pass
+ sos_cmd = f"-o kernel --encrypt-pass {encrypt_pass}"
def test_archive_gpg_encrypted(self):
self.assertOutputContains(r'/.*sosreport-.*tar.*\.gpg')
- _cmd = "file %s" % self.encrypted_path
+ _cmd = f"file {self.encrypted_path}"
res = process.run(_cmd)
self.assertTrue(
("GPG symmetrically encrypted data" in res.stdout.decode())
@@ -41,7 +41,7 @@ class EncryptedCleanedReportTest(EncryptedReportTest):
"""
encrypt_pass = 'sostest'
- sos_cmd = "-o host,networking --clean --encrypt-pass %s" % encrypt_pass
+ sos_cmd = f"-o host,networking --clean --encrypt-pass {encrypt_pass}"
def test_hostname_obfuscated(self):
self.assertFileHasContent('hostname', 'host0')
diff --git a/tests/report_tests/help_output_tests.py b/tests/report_tests/help_output_tests.py
index 8321f193..e6cf393f 100644
--- a/tests/report_tests/help_output_tests.py
+++ b/tests/report_tests/help_output_tests.py
@@ -48,4 +48,4 @@ class ReportListPluginsTest(StageOneOutputTest):
# Ignore newlines
if not ln:
continue
- assert len(ln) > 1, "Plugin '%s' missing description" % ln[0]
+ assert len(ln) > 1, f"Plugin '{ln[0]}' missing description"
diff --git a/tests/report_tests/plugin_tests/networking/networking.py b/tests/report_tests/plugin_tests/networking/networking.py
index 77afe6d5..3b15bc88 100644
--- a/tests/report_tests/plugin_tests/networking/networking.py
+++ b/tests/report_tests/plugin_tests/networking/networking.py
@@ -37,7 +37,7 @@ class NetworkingPluginTest(StageOneReportTest):
# https://lwn.net/Articles/142330/
if not dev.startswith('bonding_'):
self.assertFileGlobInArchive(
- "sos_commands/networking/ethtool_*_%s" % dev
+ f"sos_commands/networking/ethtool_*_{dev}"
)
diff --git a/tests/report_tests/smoke_tests.py b/tests/report_tests/smoke_tests.py
index 593e9a0c..94bf10b2 100644
--- a/tests/report_tests/smoke_tests.py
+++ b/tests/report_tests/smoke_tests.py
@@ -27,7 +27,7 @@ class AllPluginSmokeTest(StageOneReportTest):
"""
def pre_sos_setup(self):
- _cmd = '%s report --list-plugins' % self.sos_bin
+ _cmd = f'{self.sos_bin} report --list-plugins'
out = process.run(_cmd, timeout=300).stdout.decode()
reg = DISABLED + '(.*?)' + OPTIONS
self.plugs = []
@@ -38,7 +38,7 @@ class AllPluginSmokeTest(StageOneReportTest):
except Exception:
pass
- self.sos_cmd = '-e %s' % ','.join(p for p in self.plugs)
+ self.sos_cmd = f'-e {",".join(p for p in self.plugs)}'
def test_all_plugins_ran(self):
for plugin in self.plugs:
diff --git a/tests/sos_tests.py b/tests/sos_tests.py
index 59374501..655a9472 100644
--- a/tests/sos_tests.py
+++ b/tests/sos_tests.py
@@ -158,8 +158,8 @@ class BaseSoSTest(Test):
if err.result.interrupted:
raise Exception("Timeout exceeded, see output above")
else:
- raise Exception("Command failed, see output above: '%s'"
- % err.command.split('bin/')[1])
+ raise Exception("Command failed, see output above: "
+ f"'{err.command.split('bin/')[1]}'")
with open(os.path.join(self.tmpdir, 'output'), 'wb') as pfile:
pickle.dump(self.cmd_output, pfile)
self.cmd_output.stdout = self.cmd_output.stdout.decode()
@@ -332,11 +332,11 @@ class BaseSoSTest(Test):
def assertFileExists(self, fname):
"""Asserts that fname exists on the filesystem"""
- assert os.path.exists(fname), "%s does not exist" % fname
+ assert os.path.exists(fname), f"{fname} does not exist"
def assertFileNotExists(self, fname):
"""Asserts that fname does not exist on the filesystem"""
- assert not os.path.exists(fname), "%s exists" % fname
+ assert not os.path.exists(fname), f"{fname} exists"
def assertOutputContains(self, content):
"""Ensure that stdout did contain the given content string
@@ -347,7 +347,7 @@ class BaseSoSTest(Test):
found = re.search(
fr"(.*)?{content}(.*)?",
self.cmd_output.stdout + self.cmd_output.stderr)
- assert found, "Content string '%s' not in output" % content
+ assert found, f"Content string '{content}' not in output"
def assertOutputNotContains(self, content):
"""Ensure that stdout did NOT contain the given content string
@@ -358,7 +358,7 @@ class BaseSoSTest(Test):
found = re.search(
fr"(.*)?{content}(.*)?",
self.cmd_output.stdout + self.cmd_output.stderr)
- assert not found, "String '%s' present in stdout" % content
+ assert not found, f"String '{content}' present in stdout"
class BaseSoSReportTest(BaseSoSTest):
@@ -394,8 +394,8 @@ class BaseSoSReportTest(BaseSoSTest):
def _decrypt_archive(self, archive):
_archive = archive.strip('.gpg')
- cmd = ("gpg --batch --passphrase %s -o %s --decrypt %s"
- % (self.encrypt_pass, _archive, archive))
+ cmd = (f"gpg --batch --passphrase {self.encrypt_pass} -o {_archive} "
+ f"--decrypt {archive}")
try:
process.run(cmd, timeout=10)
except Exception as err:
@@ -415,7 +415,7 @@ class BaseSoSReportTest(BaseSoSTest):
means "grep -F")
"""
fixed_opt = "" if regexp else "F"
- cmd = "grep -ril%s '%s' %s" % (fixed_opt, search, self.archive_path)
+ cmd = f"grep -ril{fixed_opt} '{search}' {self.archive_path}"
try:
out = process.run(cmd)
rc = out.exit_status
@@ -457,7 +457,7 @@ class BaseSoSReportTest(BaseSoSTest):
archive.extract(arc_path, _extract_path)
self.archive_path = self._get_archive_path()
except Exception as err:
- self.cancel("Could not extract archive: %s" % err)
+ self.cancel(f"Could not extract archive: {err}")
def _get_extracted_tarball_path(self):
"""Based on the klass id setup earlier, provide a name to extract the
@@ -550,7 +550,7 @@ class BaseSoSReportTest(BaseSoSTest):
files = glob.glob(
os.path.join(self.archive_path, fname.lstrip('/'))
)
- assert files, "No files matching %s found" % fname
+ assert files, f"No files matching {fname} found"
def assertFileGlobNotInArchive(self, fname):
"""Ensure that there are NO files in the archive matching a given fname
@@ -580,7 +580,7 @@ class BaseSoSReportTest(BaseSoSTest):
with open(fname, 'r') as lfile:
_contents = lfile.read()
for line in _contents.splitlines():
- if re.match(".*%s.*" % content, line, re.I):
+ if re.match(f".*{content}.*", line, re.I):
matched = True
break
assert \
@@ -600,7 +600,7 @@ class BaseSoSReportTest(BaseSoSTest):
fname = self.get_name_in_archive(fname)
with open(fname, 'r') as mfile:
for line in mfile.read().splitlines():
- if re.match(".*%s.*" % content, line, re.I):
+ if re.match(f".*{content}.*", line, re.I):
matched = True
break
assert \
@@ -680,11 +680,11 @@ class BaseSoSReportTest(BaseSoSTest):
# test that all requested plugins did run
for i in plugins:
- assert i in _executed, "Requested plugin '%s' did not run" % i
+ assert i in _executed, f"Requested plugin '{i}' did not run"
# test that no unrequested plugins ran
for j in _executed:
- assert j in plugins, "Unrequested plugin '%s' ran as well" % j
+ assert j in plugins, f"Unrequested plugin '{j}' ran as well"
def get_plugin_manifest(self, plugin):
"""Get the manifest data for the specified plugin
@@ -696,7 +696,7 @@ class BaseSoSReportTest(BaseSoSTest):
:rtype: ``dict``
"""
if not self.manifest['components']['report']['plugins'][plugin]:
- raise Exception("Manifest for %s not present" % plugin)
+ raise Exception(f"Manifest for {plugin} not present")
return self.manifest['components']['report']['plugins'][plugin]
@@ -896,8 +896,8 @@ class StageTwoReportTest(BaseSoSReportTest):
installed = distro_packages.install_distro_packages(self.packages)
if not installed:
raise Exception(
- "Unable to install requested packages %s"
- % ', '.join(self.packages[self.local_distro])
+ f"Unable to install requested packages "
+ f"{', '.join(self.packages[self.local_distro])}"
)
# save installed package list to our tmpdir to be removed later
self._write_file_to_tmpdir(
@@ -1037,7 +1037,7 @@ class StageOneOutputTest(BaseSoSTest):
sos_cmd = ''
def _generate_sos_command(self):
- return "%s %s" % (self.sos_bin, self.sos_cmd)
+ return f"{self.sos_bin} {self.sos_cmd}"
@skipIf(lambda x: x._exception_expected, "Non-zero exit code expected")
def test_help_output_successful(self):
diff --git a/tests/unittests/conformance_tests.py b/tests/unittests/conformance_tests.py
index 137121ea..ea337624 100644
--- a/tests/unittests/conformance_tests.py
+++ b/tests/unittests/conformance_tests.py
@@ -31,23 +31,23 @@ class PluginConformance(unittest.TestCase):
_attr = getattr(plug, tup)
self.assertIsInstance(
_attr, tuple,
- "%s.%s is type %s" % (plug.__name__, tup, type(_attr))
+ f"{plug.__name__}.{tup} is type {type(_attr)}"
)
def test_plugin_description_is_str(self):
for plug in self.plug_classes:
self.assertIsInstance(plug.short_desc, str,
- "%s name not string" % plug.__name__)
+ f"{plug.__name__} name not string")
# make sure the description is not empty
self.assertNotEqual(plug.short_desc, '',
- "%s description unset" % plug.__name__)
+ f"{plug.__name__} description unset")
def test_plugin_name_is_str(self):
for plug in self.plug_classes:
self.assertIsInstance(plug.plugin_name, str,
- "%s name not string" % plug.__name__)
+ f"{plug.__name__} name not string")
self.assertNotEqual(plug.plugin_name, '',
- "%s name unset" % plug.__name__)
+ f"{plug.__name__} name unset")
def test_plugin_option_list_correct(self):
for plug in self.plug_classes: