[osinfo-db PATCH 2/2] tests: Add test_related

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



test_related ensures that an OS entry is not inheriting from itself (or
from another OS which would end up inheriting from itself), avoiding
them to have an infinite loop on libosinfo side.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 tests/test_related.py | 12 ++++++++++++
 tests/util.py         |  5 ++++-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 tests/test_related.py

diff --git a/tests/test_related.py b/tests/test_related.py
new file mode 100644
index 0000000..aab4cc8
--- /dev/null
+++ b/tests/test_related.py
@@ -0,0 +1,12 @@
+# This work is licensed under the GNU GPLv2 or later.
+# See the COPYING file in the top-level directory.
+
+from . import util
+
+
+@util.os_parametrize('osxml', filter_related=True)
+def test_related(osxml):
+    related = util.DataFiles.getosxml_related(osxml)
+
+    for os in related:
+        assert os is not osxml
diff --git a/tests/util.py b/tests/util.py
index b5dcd8b..d2f2763 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -62,7 +62,8 @@ class _Files():
                 p.startswith(os.path.join(self.datadir, dirname))]
 
     def oses(self, filter_media=False, filter_trees=False, filter_images=False,
-            filter_devices=False, filter_resources=False, filter_dates=False):
+            filter_devices=False, filter_resources=False, filter_dates=False,
+            filter_related=False):
         """
         Return a list of osinfo.Os objects
 
@@ -86,6 +87,8 @@ class _Files():
             oses = [o for o in oses if o.resources_list]
         if filter_dates:
             oses = [o for o in oses if o.release_date or o.eol_date]
+        if filter_related:
+            oses = [o for o in oses if self.getosxml_related(o)]
         return oses
 
     def getosxml_related(self, osxml):
-- 
2.21.0

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux