[Libosinfo] [osinfo-db PATCH v2 2/7] tests: Move ids_cb() out of os_parametrize()

Fabiano Fidêncio fidencio at redhat.com
Tue Apr 23 15:20:35 UTC 2019


Let's make it an internal function that could be used by different
parametrize functions.

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

diff --git a/tests/util.py b/tests/util.py
index f24c023..2a44b8a 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -134,16 +134,17 @@ class _DataFiles(_Files):
 DataFiles = _DataFiles()
 
 
+def _ids_cb(osxml):
+    # pytest passes us a weird value when oses is empty, which
+    # might happen depending on how agressively we filter. So
+    # we can't assume we are passed an Os instance
+    return getattr(osxml, "shortid", str(osxml))
+
+
 def os_parametrize(argname, **kwargs):
     """
     Helper for parametrizing a test with an OS list. Passthrough any
     extra arguments to DataFiles.oses()
     """
-    def ids_cb(osxml):
-        # pytest passes us a weird value when oses is empty, which
-        # might happen depending on how agressively we filter. So
-        # we can't assume we are passed an Os instance
-        return getattr(osxml, "shortid", str(osxml))
-
     oses = DataFiles.oses(**kwargs)
-    return pytest.mark.parametrize(argname, oses, ids=ids_cb)
+    return pytest.mark.parametrize(argname, oses, ids=_ids_cb)
-- 
2.21.0




More information about the Libosinfo mailing list