aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-04-22 16:02:58 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-04-28 10:16:55 -0400
commit25ccc0eab1c1c1cbf32e109be727ffdd79413a70 (patch)
tree4e9e7bfb798f955b7ed06f6af96ed32613a96364
parent1d0729a9dcfe3f3cebb961114c9bc05136cf8cfb (diff)
downloadsos-25ccc0eab1c1c1cbf32e109be727ffdd79413a70.tar.gz
[tests] Use re.search for assertOutput(Not)Contains
Standardizes the `assertOutputContains` and `assertOutputNotContains` methods to use `re.search()`, instead of separate parsing methods. `search()` replaces `match()` for efficiency purposes against the collected output. Related: #2507 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--tests/sos_tests.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/sos_tests.py b/tests/sos_tests.py
index d71fa624..590ac7bd 100644
--- a/tests/sos_tests.py
+++ b/tests/sos_tests.py
@@ -400,7 +400,8 @@ class BaseSoSReportTest(BaseSoSTest):
:param content: The string that should not be in stdout
:type content: ``str``
"""
- assert content in self.cmd_output.stdout, "Content string '%s' not in output" % content
+ found = re.search(r"(.*)?%s(.*)?" % content, self.cmd_output.stdout)
+ assert found, "Content string '%s' not in output" % content
def assertOutputNotContains(self, content):
"""Ensure that stdout did NOT contain the given content string
@@ -408,7 +409,8 @@ class BaseSoSReportTest(BaseSoSTest):
:param content: The string that should not be in stdout
:type content: ``str``
"""
- assert not re.match(".*%s.*" % content, self.cmd_output.stdout), "String '%s' present in stdout" % content
+ found = re.search(r"(.*)?%s(.*)?" % content, self.cmd_output.stdout)
+ assert not found, "String '%s' present in stdout" % content
def assertPluginIncluded(self, plugin):
"""Ensure that the specified plugin did run for the sos execution