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

Fix 'importlib.abc.TraversableResources' deprecation warning in Python 3.12 #10452

Merged
merged 3 commits into from Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/10452.bugfix.rst
@@ -0,0 +1 @@
Fix 'importlib.abc.TraversableResources' deprecation warning in Python 3.12.
7 changes: 6 additions & 1 deletion src/_pytest/assertion/rewrite.py
Expand Up @@ -275,7 +275,12 @@ def get_data(self, pathname: Union[str, bytes]) -> bytes:

if sys.version_info >= (3, 10):

def get_resource_reader(self, name: str) -> importlib.abc.TraversableResources: # type: ignore
if sys.version_info >= (3, 12):
from importlib.resources.abc import TraversableResources
else:
from importlib.abc import TraversableResources

def get_resource_reader(self, name: str) -> TraversableResources: # type: ignore
if sys.version_info < (3, 11):
from importlib.readers import FileReader
else:
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Expand Up @@ -9,6 +9,7 @@ envlist =
py39
py310
py311
py312
pypy3
py37-{pexpect,xdist,unittestextras,numpy,pluggymain,pylib}
doctesting
Expand Down