Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests relying on /dev/cdrom failing when running with pytest #51

Open
dvzrv opened this issue Sep 2, 2020 · 0 comments
Open

tests relying on /dev/cdrom failing when running with pytest #51

dvzrv opened this issue Sep 2, 2020 · 0 comments

Comments

@dvzrv
Copy link

dvzrv commented Sep 2, 2020

Hi! When packaging 1.2.0 for Arch Linux I used pytest to run the test suite (i.e. pytest -v). The way of running tests via setuptools (i.e. python setup.py test) is soon going to be deprecated hence I'm rather switching earlier than later ;-)
Unfortunately a few of the tests seem to have defaults set that can not be met (also because they assume that a cdrom drive is available. We run packaging tools in pristine systemd-nspawn containers which is why there will never be a cdrom drive though.

============================= test session starts ==============================
platform linux -- Python 3.8.5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /build/python-discid/src/python-discid-1.2.0
collecting ... collected 16 items

test_discid.py::TestModulePrivate::test_decode PASSED                    [  6%]
test_discid.py::TestModulePrivate::test_encode PASSED                    [ 12%]
test_discid.py::TestModulePrivate::test_encoding PASSED                  [ 18%]
test_discid.py::TestModule::test_default_device PASSED                   [ 25%]
test_discid.py::TestModule::test_device_encoding PASSED                  [ 31%]
test_discid.py::TestModule::test_features PASSED                         [ 37%]
test_discid.py::TestModule::test_features_implemented PASSED             [ 43%]
test_discid.py::TestModule::test_invalid_device PASSED                   [ 50%]
test_discid.py::TestModule::test_put_fail PASSED                         [ 56%]
test_discid.py::TestModule::test_put_success PASSED                      [ 62%]
test_discid.py::TestModule::test_version_string PASSED                   [ 68%]
test_discid.py::TestDisc::test_default_device PASSED                     [ 75%]
test_discid.py::TestDisc::test_features PASSED                           [ 81%]
test_discid.py::TestDisc::test_read_features FAILED                      [ 87%]
test_discid.py::TestDisc::test_read_put FAILED                           [ 93%]
test_discid.py::TestDisc::test_read_simple FAILED                        [100%]

=================================== FAILURES ===================================
_________________________ TestDisc.test_read_features __________________________

self = <test_discid.TestDisc testMethod=test_read_features>

    def test_read_features(self):
>       disc = discid.read(features=["mcn", "isrc"]) # read from default drive

test_discid.py:178:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
discid/disc.py:55: in read
    disc.read(device, features)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <discid.disc.Disc object at 0x6bc3e9d7f970>, device = None
features = ['mcn', 'isrc']

    def read(self, device=None, features=[]):
        """Reads the TOC from the device given as string

        The user is supposed to use :func:`discid.read`.
        """
        if "read" not in FEATURES:
            raise NotImplementedError("discid_read not implemented on platform")

        # only use features implemented on this platform and in this module
        self._requested_features = list(set(features) & set(FEATURES)
                                        & set(FEATURES_IMPLEMENTED))

        # create the bitmask for libdiscid
        c_features = 0
        for feature in features:
            c_features += _FEATURE_MAPPING.get(feature, 0)

        # device = None will use the default device (internally)
        try:
            result = _LIB.discid_read_sparse(self._handle, _encode(device),
                                             c_features) == 1
        except AttributeError:
            result = _LIB.discid_read(self._handle, _encode(device)) == 1
        self._success = result
        if not self._success:
>           raise DiscError(self._get_error_msg())
E           discid.disc.DiscError: cannot open device `/dev/cdrom'

discid/disc.py:152: DiscError
____________________________ TestDisc.test_read_put ____________________________

self = <test_discid.TestDisc testMethod=test_read_put>

    def test_read_put(self):
        # a read followed with a put, which should clear the features
>       disc = discid.read(features=["mcn", "isrc"]) # read from default drive

test_discid.py:196:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
discid/disc.py:55: in read
    disc.read(device, features)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <discid.disc.Disc object at 0x6bc3e9d0c700>, device = None
features = ['mcn', 'isrc']

    def read(self, device=None, features=[]):
        """Reads the TOC from the device given as string

        The user is supposed to use :func:`discid.read`.
        """
        if "read" not in FEATURES:
            raise NotImplementedError("discid_read not implemented on platform")

        # only use features implemented on this platform and in this module
        self._requested_features = list(set(features) & set(FEATURES)
                                        & set(FEATURES_IMPLEMENTED))

        # create the bitmask for libdiscid
        c_features = 0
        for feature in features:
            c_features += _FEATURE_MAPPING.get(feature, 0)

        # device = None will use the default device (internally)
        try:
            result = _LIB.discid_read_sparse(self._handle, _encode(device),
                                             c_features) == 1
        except AttributeError:
            result = _LIB.discid_read(self._handle, _encode(device)) == 1
        self._success = result
        if not self._success:
>           raise DiscError(self._get_error_msg())
E           discid.disc.DiscError: cannot open device `/dev/cdrom'

discid/disc.py:152: DiscError
__________________________ TestDisc.test_read_simple ___________________________
self = <test_discid.TestDisc testMethod=test_read_simple>

    def test_read_simple(self):
>       disc = discid.read()        # read from default drive

test_discid.py:123:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
discid/disc.py:55: in read
    disc.read(device, features)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <discid.disc.Disc object at 0x6bc3e9cd2640>, device = None, features = []

    def read(self, device=None, features=[]):
        """Reads the TOC from the device given as string

        The user is supposed to use :func:`discid.read`.
        """
        if "read" not in FEATURES:
            raise NotImplementedError("discid_read not implemented on platform")

        # only use features implemented on this platform and in this module
        self._requested_features = list(set(features) & set(FEATURES)
                                        & set(FEATURES_IMPLEMENTED))

        # create the bitmask for libdiscid
        c_features = 0
        for feature in features:
            c_features += _FEATURE_MAPPING.get(feature, 0)

        # device = None will use the default device (internally)
        try:
            result = _LIB.discid_read_sparse(self._handle, _encode(device),
                                             c_features) == 1
        except AttributeError:
            result = _LIB.discid_read(self._handle, _encode(device)) == 1
        self._success = result
        if not self._success:
>           raise DiscError(self._get_error_msg())
E           discid.disc.DiscError: cannot open device `/dev/cdrom'

discid/disc.py:152: DiscError
=========================== short test summary info ============================
FAILED test_discid.py::TestDisc::test_read_features - discid.disc.DiscError: ...
FAILED test_discid.py::TestDisc::test_read_put - discid.disc.DiscError: canno...
FAILED test_discid.py::TestDisc::test_read_simple - discid.disc.DiscError: ca...
========================= 3 failed, 13 passed in 0.13s =========================

I will disable these tests for now, as they can never be met in a packaging environment. Maybe they can be changed so that they are skipped if no cdrom drive is available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant