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

Test collection failing since pytest 8.1 #259

Closed
jaraco opened this issue Jun 19, 2024 · 0 comments
Closed

Test collection failing since pytest 8.1 #259

jaraco opened this issue Jun 19, 2024 · 0 comments

Comments

@jaraco
Copy link
Member

jaraco commented Jun 19, 2024

Two months ago, on pytest 8.0.2, tests were passing.

Now, on Python 3.11 and earlier, tests are failing.

On pytest 8.2, test collection fails:

_________________________________________________ ERROR collecting distutils/cygwinccompiler.py __________________________________________________
ImportError while importing test module '/Users/jaraco/code/pypa/distutils/distutils/cygwinccompiler.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
distutils/cygwinccompiler.py:27: in <module>
    from .version import LooseVersion, suppress_known_deprecation
E   ImportError: cannot import name 'suppress_known_deprecation' from 'distutils.version' (/opt/homebrew/Cellar/[email protected]/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/distutils/version.py)
____________________________________________ ERROR collecting distutils/tests/test_cygwinccompiler.py ____________________________________________
ImportError while importing test module '/Users/jaraco/code/pypa/distutils/distutils/tests/test_cygwinccompiler.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
distutils/tests/test_cygwinccompiler.py:6: in <module>
    from distutils.cygwinccompiler import (
E   ImportError: cannot import name 'CONFIG_H_NOTOK' from 'distutils.cygwinccompiler' (/Users/jaraco/code/pypa/distutils/distutils/cygwinccompiler.py)
_____________________________________________ ERROR collecting distutils/tests/test_unixccompiler.py _____________________________________________
ImportError while importing test module '/Users/jaraco/code/pypa/distutils/distutils/tests/test_unixccompiler.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
distutils/tests/test_unixccompiler.py:10: in <module>
    from distutils.util import _clear_cached_macosx_ver
E   ImportError: cannot import name '_clear_cached_macosx_ver' from 'distutils.util' (/opt/homebrew/Cellar/[email protected]/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/distutils/util.py)

Additionally, a warning is emitted about importing distutils from stdlib:

<frozen importlib.util>:95
  <frozen importlib.util>:95: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

../../../../../opt/homebrew/Cellar/[email protected]/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/distutils/util.py:92
  /opt/homebrew/Cellar/[email protected]/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/distutils/util.py:92: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
    import _osx_support, distutils.sysconfig

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Pinning to pytest 8.1, the collection succeeds, but the tests fail when they end up importing distutils from the stdlib. For example:

___________________________________________________________ TestMetadata.test_provides ___________________________________________________________

self = <distutils.tests.test_dist.TestMetadata object at 0x103adb950>

    def test_provides(self):
        attrs = {
            "name": "package",
            "version": "1.0",
            "provides": ["package", "package.sub"],
        }
>       dist = Distribution(attrs)

distutils/tests/test_dist.py:285: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
distutils/dist.py:259: in __init__
    getattr(self.metadata, "set_" + key)(val)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <distutils.dist.DistributionMetadata object at 0x103f7ce10>, value = ['package', 'package.sub']

    def set_provides(self, value):
        value = [v.strip() for v in value]
        for v in value:
            import distutils.versionpredicate
    
>           distutils.versionpredicate.split_provision(v)
E           AttributeError: module 'distutils' has no attribute 'versionpredicate'

distutils/dist.py:1266: AttributeError

Pinning to pytest<8.1 allows the tests to pass again.

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