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

No module named 'importlib.readers' error when importing requests with pytest 7.0.0 #9663

Closed
dave-edison opened this issue Feb 11, 2022 · 1 comment

Comments

@dave-edison
Copy link

have a module with directory structure like so:

.
├── mod
│   └── __init__.py
├── pytest.ini
└── tests
    ├── __init__.py # empty
    └── test.py
# mod/__init__.py

import requests
# tests/test.py

import mod

def test():
    assert True
# pytest.ini

[pytest]
testpaths =
    tests
python_files = *.py

using pytest==7.0.0:

$ pytest
====================================== test session starts =======================================
platform darwin -- Python 3.9.2, pytest-7.0.0, pluggy-1.0.0
rootdir: /Users/david/pytest-issue, configfile: pytest.ini, testpaths: tests
collected 0 items / 1 error                                                                      

============================================= ERRORS =============================================
_________________________________ ERROR collecting tests/test.py _________________________________
ImportError while importing test module '/Users/david/pytest-issue/tests/test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test.py:1: in <module>
    import mod
mod/__init__.py:1: in <module>
    import requests
.venv/lib/python3.9/site-packages/requests/__init__.py:133: in <module>
    from . import utils
.venv/lib/python3.9/site-packages/requests/utils.py:42: in <module>
    DEFAULT_CA_BUNDLE_PATH = certs.where()
.venv/lib/python3.9/site-packages/certifi/core.py:36: in where
    _CACERT_CTX = get_path("certifi", "cacert.pem")
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/resources.py:161: in path
    reader = _get_resource_reader(_get_package(package))
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/resources.py:76: in _get_resource_reader
    spec.loader.get_resource_reader(spec.name))
E   ModuleNotFoundError: No module named 'importlib.readers'
==================================== short test summary info =====================================
ERROR tests/test.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================== 1 error in 0.20s ========================================

using pytest==6.2.5:

$ pytest
============================================ test session starts ============================================
platform darwin -- Python 3.9.2, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/david/pytest-issue, configfile: pytest.ini, testpaths: tests
collected 1 item                                                                                            

tests/test.py .                                                                                       [100%]

============================================= 1 passed in 0.42s =============================================

On MacOS catalina python 3.9.2, using requests==2.27.1, but I have also observed this same issue on ubuntu 20 / python 3.9.10

@dave-edison
Copy link
Author

ah I see #9608, sorry for the dupe, closing this

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