[Libosinfo] [osinfo-db 2/2] test_isoinfo: Allow running a quickier version of the test

Fabiano Fidêncio fidencio at redhat.com
Mon Mar 18 21:28:24 UTC 2019


test_isoinfo takes a lot of time if running in the way it's been
implemented.

Let's add an environment variable to decide whether we want to run a
"quickier" or an expensive version of the test.

The quicker version would just test against the expected OS and ensure a
match happens, while the expensive version tests against all other OSes
to ensure we don't the media info does not match against any other OS by
mistake.

The environment variable added is OSINFO_DB_ENABLE_EXPENSIVE and it
expects an integer, as in 0 (or not passing it at all) to disable the
expensive test or non zero to enable it.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 tests/test_isoinfo.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/test_isoinfo.py b/tests/test_isoinfo.py
index 504892c..a26932d 100644
--- a/tests/test_isoinfo.py
+++ b/tests/test_isoinfo.py
@@ -16,12 +16,18 @@ def _os_id(_os):
 
 @pytest.mark.parametrize('_os', [*OSES], ids=_os_id)
 def test_iso_detection(_os):
+    expensive = os.environ.get('OSINFO_DB_ENABLE_EXPENSIVE')
+    if expensive is not None:
+        expensive = int(expensive)
+    expensive = bool(expensive)
     for isodatamedia in _get_isodatamedias(_os):
         detected = []
         for __os in OSES:
+            if not expensive and _os.shortid != __os.shortid:
+                continue
             for media in __os.medias:
                 if isodatamedia.match(media.iso):
-                    if _os.shortid != __os.shortid:
+                    if expensive and _os.shortid != __os.shortid:
                         logging.warning(
                             'ISO \'%s\' was matched by OS \'%s\' while it '
                             'should only be matched by OS \'%s\'',
-- 
2.20.1




More information about the Libosinfo mailing list