diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2021-04-16 13:42:02 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-05-05 09:54:51 -0400 |
commit | 5645cf760a5fa6a9f8d95fe2a2a23a7f4a17226a (patch) | |
tree | 5c4dc4702aa5be10391038682e2b33e5ae71d29a /tests/sos_tests.py | |
parent | 50c1ed649429b5e8dc76bd0427cb84e074ecfda1 (diff) | |
download | sos-5645cf760a5fa6a9f8d95fe2a2a23a7f4a17226a.tar.gz |
[tests] assertFileGlobInArchive should only fail if file is present
Like `assertFileCollected`, `assertFileGlobInArchive` should only fail
if the referenced collection is not in the archive *and* it is present
on the test system. If it is not present on the test system, sos cannot
collect it and it is thus not an error to be missing from the archive.
Related: #2499
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/sos_tests.py')
-rw-r--r-- | tests/sos_tests.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/sos_tests.py b/tests/sos_tests.py index 07308561..1279755b 100644 --- a/tests/sos_tests.py +++ b/tests/sos_tests.py @@ -315,7 +315,8 @@ class BaseSoSReportTest(BaseSoSTest): """ if os.path.exists(fname): self.assertFileExists(self.get_name_in_archive(fname)) - assert True + else: + assert True def assertFileNotCollected(self, fname): """Ensure that a given fname is NOT in the extracted archive @@ -327,13 +328,16 @@ class BaseSoSReportTest(BaseSoSTest): def assertFileGlobInArchive(self, fname): """Ensure that at least one file in the archive matches a given fname - glob + glob, iff it exists on the host system :param fname: The glob to match filenames of :type fname: ``str`` """ - files = glob.glob(os.path.join(self.archive_path, fname.lstrip('/'))) - assert files, "No files matching %s found" % fname + if not glob.glob(fname): + assert True + else: + files = glob.glob(os.path.join(self.archive_path, fname.lstrip('/'))) + assert files, "No files matching %s found" % fname def assertFileGlobNotInArchive(self, fname): """Ensure that there are NO files in the archive matching a given fname |