On Wed, 2019-03-20 at 17:53 -0400, Cole Robinson wrote: > This is a helper for parameterizing tests based on a list of OS > objects. > > Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> > --- > tests/test_devices.py | 4 +--- > tests/test_resources.py | 11 +++++------ > tests/test_urls.py | 6 +++--- > tests/util.py | 10 ++++++++++ > 4 files changed, 19 insertions(+), 12 deletions(-) > > diff --git a/tests/test_devices.py b/tests/test_devices.py > index c14ae48..8696ccc 100644 > --- a/tests/test_devices.py > +++ b/tests/test_devices.py > @@ -1,12 +1,10 @@ > # This work is licensed under the GNU GPLv2 or later. > # See the COPYING file in the top-level directory. > > -import pytest > - > from . import util > > > -@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: > o.shortid) > +@util.os_parametrize('_os') > def test_devices_duplication(_os): > broken = [] > related = util.DataFiles.get_os_related(_os) > diff --git a/tests/test_resources.py b/tests/test_resources.py > index d8cc588..6e00dba 100644 > --- a/tests/test_resources.py > +++ b/tests/test_resources.py > @@ -4,12 +4,11 @@ > from collections import defaultdict > > import logging > -import pytest > > from . import util > > > -@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: > o.shortid) > +@util.os_parametrize('_os') > def test_resources_uniqueness_by_arch(_os): > result = defaultdict(list) > for resources in _os.resources_list: > @@ -19,7 +18,7 @@ def test_resources_uniqueness_by_arch(_os): > assert len(value) == 1 > > > -@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: > o.shortid) > +@util.os_parametrize('_os') > def test_minimum_recommended_resources(_os): > _resources_helper(_os, > _os.get_minimum_resources, > @@ -28,7 +27,7 @@ def test_minimum_recommended_resources(_os): > 'recommended') > > > -@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: > o.shortid) > +@util.os_parametrize('_os') > def test_recommended_maximum_resources(_os): > _resources_helper(_os, > _os.get_recommended_resources, > @@ -37,7 +36,7 @@ def test_recommended_maximum_resources(_os): > 'maximum') > > > -@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: > o.shortid) > +@util.os_parametrize('_os') > def test_recommended_network_install_resources(_os): > _resources_helper(_os, > _os.get_recommended_resources, > @@ -46,7 +45,7 @@ def > test_recommended_network_install_resources(_os): > 'network-install') > > > -@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: > o.shortid) > +@util.os_parametrize('_os') > def test_network_install_maximum_resources(_os): > _resources_helper(_os, > _os.get_network_install_resources, > diff --git a/tests/test_urls.py b/tests/test_urls.py > index 4cc38e7..b6dcd62 100644 > --- a/tests/test_urls.py > +++ b/tests/test_urls.py > @@ -7,7 +7,7 @@ import pytest > from . import util > > > -@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: > o.shortid) > +@util.os_parametrize('_os') > @pytest.mark.skipif(os.environ.get('OSINFO_DB_NETWORK_TESTS') is > None, > reason='Network related tests are not enabled') > def test_images_url(_os): > @@ -19,7 +19,7 @@ def test_images_url(_os): > assert broken == [] > > > -@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: > o.shortid) > +@util.os_parametrize('_os') > @pytest.mark.skipif(os.environ.get('OSINFO_DB_NETWORK_TESTS') is > None, > reason='Network related tests are not enabled') > def test_medias_url(_os): > @@ -31,7 +31,7 @@ def test_medias_url(_os): > assert broken == [] > > > -@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: > o.shortid) > +@util.os_parametrize('_os') > @pytest.mark.skipif(os.environ.get('OSINFO_DB_NETWORK_TESTS') is > None, > reason='Network related tests are not enabled') > def test_trees_url(_os): > diff --git a/tests/util.py b/tests/util.py > index b957b08..76e08da 100644 > --- a/tests/util.py > +++ b/tests/util.py > @@ -6,6 +6,8 @@ from collections import defaultdict > import os > import xml.etree.ElementTree as ET > > +import pytest > + > from . import osinfo > > > @@ -82,3 +84,11 @@ class _DataFiles(): > > > DataFiles = _DataFiles() > + > + > +def os_parametrize(argname): > + """ > + Helper for parametrizing a test with an OS list. > + """ > + oses = DataFiles.oses() > + return pytest.mark.parametrize(argname, oses, ids=lambda o: > o.shortid) Reviewed-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> Best Regards, -- Fabiano Fidêncio _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo