diff --git a/tests/utils/test_exceptions.py b/tests/utils/test_exceptions.py index b3cdf96faf..297993d905 100644 --- a/tests/utils/test_exceptions.py +++ b/tests/utils/test_exceptions.py @@ -17,7 +17,10 @@ def create_exception_object(exception_name: str): ) # get required arg types of exception class by inspecting its __init__ method - required_args = inspect.get_annotations(exception_class.__init__) + if hasattr(inspect, 'get_annotations'): + required_args = inspect.get_annotations(exception_class.__init__) + else: + required_args = exception_class.__init__.__annotations__ # python 3.9 and below # create a dictionary of required args with default values