To not collide with the 'os' module, we use the name '_os' to represent an osinfo.Os instance in the test code. Leading underscore often means 'private' or 'ignore this' to static analysis tools so the naming is not ideal IMO. Rename _os arguments to 'osxml' and '__os' to 'osxml2' Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- tests/test_devices.py | 14 +++++------ tests/test_isoinfo.py | 14 +++++------ tests/test_resources.py | 52 +++++++++++++++++++++-------------------- tests/test_urls.py | 18 +++++++------- tests/util.py | 34 +++++++++++++-------------- 5 files changed, 67 insertions(+), 65 deletions(-) diff --git a/tests/test_devices.py b/tests/test_devices.py index 0bcf8fb..ac66b78 100644 --- a/tests/test_devices.py +++ b/tests/test_devices.py @@ -4,13 +4,13 @@ from . import util -@util.os_parametrize('_os', filter_devices=True) -def test_devices_duplication(_os): +@util.os_parametrize('osxml', filter_devices=True) +def test_devices_duplication(osxml): broken = [] - related = util.DataFiles.get_os_related(_os) - for __os in related: - if __os.devices is not None: - for device in __os.devices: - if device in _os.devices: + related = util.DataFiles.getosxml_related(osxml) + for osxml2 in related: + if osxml2.devices is not None: + for device in osxml2.devices: + if device in osxml.devices: broken.append(device) assert broken == [] diff --git a/tests/test_isoinfo.py b/tests/test_isoinfo.py index 4d70d87..07d6550 100644 --- a/tests/test_isoinfo.py +++ b/tests/test_isoinfo.py @@ -36,23 +36,23 @@ def test_iso_detection(testdata): detected = [] isodatamedia = _get_isodatamedia(isodatapath) - for __os in util.DataFiles.oses(): - for media in __os.medias: + for osxml2 in util.DataFiles.oses(): + for media in osxml2.medias: if isodatamedia.match(media.iso): - if osname != __os.shortid: + if osname != osxml2.shortid: logging.warning( 'ISO \'%s\' was matched by OS \'%s\' while it ' 'should only be matched by OS \'%s\'', - isodatamedia.filename, __os.shortid, osname) + isodatamedia.filename, osxml2.shortid, osname) else: logging.info('ISO \'%s\' matched by OS \'%s\'', - isodatamedia.filename, __os.shortid) + isodatamedia.filename, osxml2.shortid) # For several distros we do not have the volume-size # set as part of our DB, thus multiple detections may # occur. Although this case is not the optimal, as long # as we detect the very same distro it's okay-ish. - if __os.shortid not in detected: - detected.append(__os.shortid) + if osxml2.shortid not in detected: + detected.append(osxml2.shortid) if len(detected) != 1: logging.warning('Some ISOs have been matched several times by ' diff --git a/tests/test_resources.py b/tests/test_resources.py index 902e570..01b0ef7 100644 --- a/tests/test_resources.py +++ b/tests/test_resources.py @@ -8,68 +8,70 @@ import logging from . import util -@util.os_parametrize('_os', filter_resources=True) -def test_resources_uniqueness_by_arch(_os): +@util.os_parametrize('osxml', filter_resources=True) +def test_resources_uniqueness_by_arch(osxml): """ Ensure there's no more than one resource element per architecture """ result = defaultdict(list) - for resources in _os.resources_list: + for resources in osxml.resources_list: result[resources.get('arch')].append(resources) for value in result.values(): assert len(value) == 1 -@util.os_parametrize('_os', filter_resources=True) -def test_minimum_recommended_resources(_os): +@util.os_parametrize('osxml', filter_resources=True) +def test_minimum_recommended_resources(osxml): """ Ensure there's no minimum resources with bigger values than recommended resources """ - _resources_helper(_os, - _os.get_minimum_resources, + _resources_helper(osxml, + osxml.get_minimum_resources, 'minimum', - _os.get_recommended_resources, + osxml.get_recommended_resources, 'recommended') -@util.os_parametrize('_os', filter_resources=True) -def test_recommended_maximum_resources(_os): +@util.os_parametrize('osxml', filter_resources=True) +def test_recommended_maximum_resources(osxml): """ Ensure there's no recommended resources with bigger values than maximum resources """ - _resources_helper(_os, - _os.get_recommended_resources, + _resources_helper(osxml, + osxml.get_recommended_resources, 'recommended', - _os.get_maximum_resources, + osxml.get_maximum_resources, 'maximum') -@util.os_parametrize('_os', filter_resources=True) -def test_recommended_network_install_resources(_os): +@util.os_parametrize('osxml', filter_resources=True) +def test_recommended_network_install_resources(osxml): """ Ensure there's no recommended resources with bigger values than network-install resources """ - _resources_helper(_os, - _os.get_recommended_resources, + _resources_helper(osxml, + osxml.get_recommended_resources, 'recommended', - _os.get_network_install_resources, + osxml.get_network_install_resources, 'network-install') -@util.os_parametrize('_os', filter_resources=True) -def test_network_install_maximum_resources(_os): +@util.os_parametrize('osxml', filter_resources=True) +def test_network_install_maximum_resources(osxml): """ Ensure there's no network-install resources with bigger values than maximum resources """ - _resources_helper(_os, - _os.get_network_install_resources, + _resources_helper(osxml, + osxml.get_network_install_resources, 'network-install', - _os.get_maximum_resources, + osxml.get_maximum_resources, 'maximum') -def _resources_helper(_os, smaller_func, smaller_str, bigger_func, bigger_str): +def _resources_helper(osxml, + smaller_func, smaller_str, + bigger_func, bigger_str): broken = [] - for resource in _os.resources_list: + for resource in osxml.resources_list: logging.info("resources | arch: %s", resource.get('arch')) smaller = smaller_func(resource) bigger = bigger_func(resource) diff --git a/tests/test_urls.py b/tests/test_urls.py index 5900f3d..0639fe9 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -4,30 +4,30 @@ from . import util -@util.os_parametrize('_os', filter_images=True) -def test_images_url(_os): +@util.os_parametrize('osxml', filter_images=True) +def test_images_url(osxml): broken = [] - for image in _os.images: + for image in osxml.images: if image.url: if not image.url.check(): broken.append(image.url) assert broken == [] -@util.os_parametrize('_os', filter_trees=True) -def test_medias_url(_os): +@util.os_parametrize('osxml', filter_trees=True) +def test_medias_url(osxml): broken = [] - for media in _os.medias: + for media in osxml.medias: if media.url: if not media.url.check(): broken.append(media.url) assert broken == [] -@util.os_parametrize('_os', filter_media=True) -def test_trees_url(_os): +@util.os_parametrize('osxml', filter_media=True) +def test_trees_url(osxml): broken = [] - for tree in _os.trees: + for tree in osxml.trees: if tree.url: if not tree.url.check(): broken.append(tree.url) diff --git a/tests/util.py b/tests/util.py index 08fbd3f..ac90af9 100644 --- a/tests/util.py +++ b/tests/util.py @@ -72,31 +72,31 @@ class _DataFiles(): oses = [o for o in oses if o.resources_list] return oses - def get_os_related(self, _os): - if _os.internal_id not in self._os_related_cache: + def getosxml_related(self, osxml): + if osxml.internal_id not in self._os_related_cache: directly_related = [] - if _os.derives_from is not None: - for __os in self.oses(): - if _os.derives_from == __os.internal_id: - directly_related.append(__os) + if osxml.derives_from is not None: + for osxml2 in self.oses(): + if osxml.derives_from == osxml2.internal_id: + directly_related.append(osxml2) break - if _os.clones is not None: - for __os in self.oses(): - if _os.clones == __os.internal_id: - directly_related.append(__os) + if osxml.clones is not None: + for osxml2 in self.oses(): + if osxml.clones == osxml2.internal_id: + directly_related.append(osxml2) break - self._os_related_cache[_os.internal_id].extend(directly_related) + self._os_related_cache[osxml.internal_id].extend(directly_related) related = [] - for __os in directly_related: - related.extend(self.get_os_related(__os)) + for osxml2 in directly_related: + related.extend(self.getosxml_related(osxml2)) - for __os in related: - if __os not in self._os_related_cache[_os.internal_id]: - self._os_related_cache[_os.internal_id].append(__os) - return self._os_related_cache[_os.internal_id] + for osxml2 in related: + if osxml2 not in self._os_related_cache[osxml.internal_id]: + self._os_related_cache[osxml.internal_id].append(osxml2) + return self._os_related_cache[osxml.internal_id] def xmls(self): return self._get_all_xml() -- 2.21.0 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo