astropy / extension-helpers

Helpers to assist with building Python packages with compiled C/Cython extensions
https://extension-helpers.readthedocs.io
BSD 3-Clause "New" or "Revised" License
16 stars 12 forks source link

test_openmp setup error on the installed package #17

Closed olebole closed 2 years ago

olebole commented 4 years ago

When I install the package and then try to run the tests, I get the following error:

____________________________ ERROR at setup of test_add_openmp_flags_if_available _____________________________

self = <_pytest.config.Config object at 0x7f1f292ea760>, name = '--openmp-expected', default = <NOTSET>
skip = False

    def getoption(self, name, default=notset, skip=False):
        """…"""
        name = self._opt2dest.get(name, name)
        try:
>           val = getattr(self.option, name)
E           AttributeError: 'Namespace' object has no attribute '--openmp-expected'

/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1054: AttributeError

During handling of the above exception, another exception occurred:

request = <SubRequest 'openmp_expected' for <Function test_add_openmp_flags_if_available>>

    @pytest.fixture
    def openmp_expected(request):
>       openmp_expected = request.config.getoption("--openmp-expected")

/usr/lib/python3/dist-packages/extension_helpers/tests/test_openmp_helpers.py:15: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.config.Config object at 0x7f1f292ea760>, name = '--openmp-expected', default = <NOTSET>
skip = False

    def getoption(self, name, default=notset, skip=False):
        """…"""
        name = self._opt2dest.get(name, name)
        try:
            val = getattr(self.option, name)
            if val is None and skip:
                raise AttributeError(name)
            return val
        except AttributeError:
            if default is not notset:
                return default
            if skip:
                import pytest

                pytest.skip("no %r option found" % (name,))
>           raise ValueError("no option named %r" % (name,))
E           ValueError: no option named '--openmp-expected'

/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1065: ValueError
______________________________ ERROR at setup of test_generate_openmp_enabled_py _______________________________

self = <_pytest.config.Config object at 0x7f1f292ea760>, name = '--openmp-expected', default = <NOTSET>
skip = False

    def getoption(self, name, default=notset, skip=False):
        """…"""
        name = self._opt2dest.get(name, name)
        try:
>           val = getattr(self.option, name)
E           AttributeError: 'Namespace' object has no attribute '--openmp-expected'

/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1054: AttributeError

During handling of the above exception, another exception occurred:

request = <SubRequest 'openmp_expected' for <Function test_generate_openmp_enabled_py>>

    @pytest.fixture
    def openmp_expected(request):
>       openmp_expected = request.config.getoption("--openmp-expected")

/usr/lib/python3/dist-packages/extension_helpers/tests/test_openmp_helpers.py:15: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.config.Config object at 0x7f1f292ea760>, name = '--openmp-expected', default = <NOTSET>
skip = False

    def getoption(self, name, default=notset, skip=False):
        """…"""
        name = self._opt2dest.get(name, name)
        try:
            val = getattr(self.option, name)
            if val is None and skip:
                raise AttributeError(name)
            return val
        except AttributeError:
            if default is not notset:
                return default
            if skip:
                import pytest

                pytest.skip("no %r option found" % (name,))
>           raise ValueError("no option named %r" % (name,))
E           ValueError: no option named '--openmp-expected'

Since the test runs nicely during the build, I would suspect that I miss something; however I have the same dependencies installed (namely the distutils, and setuptools packages, and the Python development environment).

lupinix commented 4 years ago

Getting the same while attempting to package for Fedora.

astrofrog commented 2 years ago

The problem is that this option is defined in the conftest.py file which is at the root of the repo and not getting installed. It might be sufficient to move that file into the module itself, I can try and check soon.

astrofrog commented 2 years ago

I believe this will be fixed by https://github.com/astropy/extension-helpers/pull/37

astrofrog commented 2 years ago

@olebole @lupinix - this should be fixed in extension-helpers 1.0.0, released today. If not, please feel free to re-open!