From c6b2b3b634527094119c324fea43ebef74891241 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Tue, 21 Mar 2023 21:08:44 +0100 Subject: Replace mock._importer with pkgutil.resolve_name in test autospec mock._importer was removed in 3.11 --- tests/_autospec.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/_autospec.py') diff --git a/tests/_autospec.py b/tests/_autospec.py index ee2fc1973..ecff6bcbe 100644 --- a/tests/_autospec.py +++ b/tests/_autospec.py @@ -1,5 +1,6 @@ import contextlib import functools +import pkgutil import unittest.mock from typing import Callable @@ -51,7 +52,7 @@ def autospec(target, *attributes: str, pass_mocks: bool = True, **patch_kwargs) # Import the target if it's a string. # This is to support both object and string targets like patch.multiple. if type(target) is str: - target = unittest.mock._importer(target) + target = pkgutil.resolve_name(target) def decorator(func): for attribute in attributes: -- cgit v1.2.3