[Libosinfo] [PATCH osinfo-db 1/7] tests: test_isoinfo: Remove shortid from _ISODataMedia

Fabiano Fidêncio fidencio at redhat.com
Thu Mar 21 12:06:00 UTC 2019


On Wed, 2019-03-20 at 17:53 -0400, Cole Robinson wrote:
> It's unused, and conceptually it doesn't really belong to this class
> 
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
>  tests/test_isoinfo.py | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/test_isoinfo.py b/tests/test_isoinfo.py
> index beebcd2..3476ea9 100644
> --- a/tests/test_isoinfo.py
> +++ b/tests/test_isoinfo.py
> @@ -38,11 +38,10 @@ def test_iso_detection(_os):
>  
>  
>  class _ISODataMedia():
> -    def __init__(self, filename, shortid, volumeid, publisherid,
> systemid,
> +    def __init__(self, filename, volumeid, publisherid, systemid,
>                   applicationid, volumesize):
>  
>          self.filename = filename
> -        self.shortid = shortid
>          self.volumeid = volumeid if volumeid is not None else ''
>          self.publisherid = publisherid if publisherid is not None
> else ''
>          self.systemid = systemid if systemid is not None else ''
> @@ -95,7 +94,7 @@ def _get_volumesize(string):
>      return _get_value(string, 'Volume size is: ', int)
>  
>  
> -def _get_isodatamedia(filepath, shortid):
> +def _get_isodatamedia(filepath):
>      volumeid = None
>      publisherid = None
>      systemid = None
> @@ -123,7 +122,7 @@ def _get_isodatamedia(filepath, shortid):
>      else:
>          volumesize = None
>  
> -    return _ISODataMedia(filepath, shortid, volumeid, publisherid,
> systemid,
> +    return _ISODataMedia(filepath, volumeid, publisherid, systemid,
>                           applicationid, volumesize)
>  
>  

As the patch is we'd get the following errors when running the isoinfo
tests:

_______________________ test_iso_detection[altlinux3.0]
________________________

_os = <tests.osinfo.Os object at 0x7fcd7cde36d8>

    @pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda
o: o.shortid)
    def test_iso_detection(_os):
>       for isodatamedia in _get_isodatamedias(_os):

tests/test_isoinfo.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ 

_os = <tests.osinfo.Os object at 0x7fcd7cde36d8>

    def _get_isodatamedias(_os):
        isodata_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            'isodata')
        shortid_path = os.path.join(isodata_path, _os.distro,
_os.shortid)
    
        medias = []
        if not os.path.exists(shortid_path):
            return []
    
        for _file in os.listdir(shortid_path):
            path = os.path.join(shortid_path, _file)
            if not os.path.exists(path):
                continue
    
>           medias.append(_get_isodatamedia(path, _os.shortid))
E           TypeError: _get_isodatamedia() takes 1 positional argument
but 2 were given

tests/test_isoinfo.py:144: TypeError

I'll squash the following one-liner to solve the issue:
fidencio at laerte ~/src/upstream/osinfo-db $ git diff
diff --git a/tests/test_isoinfo.py b/tests/test_isoinfo.py
index 3476ea9..b4f6205 100644
--- a/tests/test_isoinfo.py
+++ b/tests/test_isoinfo.py
@@ -141,5 +141,5 @@ def _get_isodatamedias(_os):
         if not os.path.exists(path):
             continue
 
-        medias.append(_get_isodatamedia(path, _os.shortid))
+        medias.append(_get_isodatamedia(path))
     return medias

Reviewed-by: Fabiano Fidêncio <fidencio at redhat.com>

Best Regards,
-- 
Fabiano Fidêncio




More information about the Libosinfo mailing list