- [E302] expected 2 blank lines, found 1 - [E713] test for membership should be 'not in' - [E304] blank lines found after function decorator - C0301: Line too long (96/80) (line-too-long) Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- tests/osinfo.py | 1 - tests/test_isoinfo.py | 17 ++++++++++++++--- tests/test_urls.py | 5 ++++- tests/test_validation.py | 4 ++-- tests/util.py | 5 +++++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/osinfo.py b/tests/osinfo.py index 4b1aa55..f8ae9e1 100644 --- a/tests/osinfo.py +++ b/tests/osinfo.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 - from http.client import responses import logging diff --git a/tests/test_isoinfo.py b/tests/test_isoinfo.py index a26932d..db23c68 100644 --- a/tests/test_isoinfo.py +++ b/tests/test_isoinfo.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 - import logging import os import re @@ -11,9 +10,11 @@ from . import util OSES = util.oses() + def _os_id(_os): return _os.shortid + @pytest.mark.parametrize('_os', [*OSES], ids=_os_id) def test_iso_detection(_os): expensive = os.environ.get('OSINFO_DB_ENABLE_EXPENSIVE') @@ -39,7 +40,7 @@ def test_iso_detection(_os): # 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 not __os.shortid in detected: + if __os.shortid not in detected: detected.append(__os.shortid) if len(detected) != 1: @@ -74,7 +75,8 @@ class _ISODataMedia(): if volumesize == 0: volumesize = self.volumesize - logging.warning("media.volumeid: %s | self.volumeid: %s", media.volumeid, self.volumeid) + logging.warning("media.volumeid: %s | self.volumeid: %s", + media.volumeid, self.volumeid) if bool(re.match(media.volumeid, self.volumeid)) and \ bool(re.match(media.publisherid, self.publisherid)) and \ bool(re.match(media.applicationid, self.applicationid)) and \ @@ -84,29 +86,37 @@ class _ISODataMedia(): return False + def _get_value(string, prefix, return_type=str): if string.startswith(prefix): return return_type(string.split(': ')[-1].strip()) return None + def _get_volumeid(string): return _get_value(string, 'Volume id: ') + def _get_publisherid(string): return _get_value(string, 'Publisher id: ') + def _get_systemid(string): return _get_value(string, 'System id: ') + def _get_applicationid(string): return _get_value(string, 'Application id: ') + def _get_logicalblock(string): return _get_value(string, 'Logical block size is: ', int) + def _get_volumesize(string): return _get_value(string, 'Volume size is: ', int) + def _get_isodatamedia(filepath, shortid): volumeid = None publisherid = None @@ -138,6 +148,7 @@ def _get_isodatamedia(filepath, shortid): return _ISODataMedia(filepath, shortid, volumeid, publisherid, systemid, applicationid, volumesize) + def _get_isodatamedias(_os): isodata_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), diff --git a/tests/test_urls.py b/tests/test_urls.py index ddb0c3d..dab4117 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 - import os import pytest @@ -9,9 +8,11 @@ from . import util OSES = util.oses() + def _os_id(_os): return _os.shortid + @pytest.mark.parametrize('_os', [*OSES], ids=_os_id) @pytest.mark.skipif(os.environ.get('OSINFO_DB_NETWORK_TESTS') is None, reason='Network related tests are not enabled') @@ -23,6 +24,7 @@ def test_images_url(_os): broken.append(image.url) assert broken == [] + @pytest.mark.parametrize('_os', [*OSES], ids=_os_id) @pytest.mark.skipif(os.environ.get('OSINFO_DB_NETWORK_TESTS') is None, reason='Network related tests are not enabled') @@ -34,6 +36,7 @@ def test_medias_url(_os): broken.append(media.url) assert broken == [] + @pytest.mark.parametrize('_os', [*OSES], ids=_os_id) @pytest.mark.skipif(os.environ.get('OSINFO_DB_NETWORK_TESTS') is None, reason='Network related tests are not enabled') diff --git a/tests/test_validation.py b/tests/test_validation.py index 5234e5f..275cbcf 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 - import libxml2 import pytest @@ -12,11 +11,12 @@ SCHEMA = util.schema() PARSER = libxml2.relaxNGNewParserCtxt(SCHEMA) VALID = PARSER.relaxNGParse().relaxNGNewValidCtxt() + def _file_id(_file): return _file -@pytest.mark.parametrize('_file', [*XMLS], ids=_file_id) +@pytest.mark.parametrize('_file', [*XMLS], ids=_file_id) def test_validation(_file): doc = libxml2.parseFile(_file) assert VALID.relaxNGValidateDoc(doc) == 0 diff --git a/tests/util.py b/tests/util.py index ed1ae68..48e106e 100644 --- a/tests/util.py +++ b/tests/util.py @@ -6,6 +6,7 @@ import xml.etree.ElementTree as ET from . import osinfo + def _get_files(directory): files = [] datadir = os.environ.get('INTERNAL_OSINFO_DB_DATA_DIR') @@ -20,6 +21,7 @@ def _get_files(directory): logging.error('INTERNAL_OSINFO_DB_DATA_DIR is not set') return files + def _get_os(path): tree = ET.parse(path) root = tree.getroot() @@ -27,6 +29,7 @@ def _get_os(path): _os = root.find('os') return _os + def oses(): _oses = [] files = _get_files('os') @@ -35,9 +38,11 @@ def oses(): _oses.append(osinfo.Os(_get_os(_file))) return _oses + def xmls(): return _get_files('') + def schema(): _schema = None datadir = os.environ.get('INTERNAL_OSINFO_DB_DATA_DIR') -- 2.21.0 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo