Skip to content

Commit

Permalink
Fix 'importlib.abc.TraversableResources' deprecation warning in Pytho…
Browse files Browse the repository at this point in the history
…n 3.12 (#10452)
  • Loading branch information
hugovk committed Oct 31, 2022
1 parent 8e2de91 commit 0314b50
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
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

0 comments on commit 0314b50

Please sign in to comment.