From 3af163222388a9ae2c055b41f4ac6e4216277e6b Mon Sep 17 00:00:00 2001 From: Joakim Soderlund Date: Sun, 25 Sep 2022 13:38:44 +0200 Subject: [PATCH] Fix deprecation warning in response fixture --- tests/fixtures/responses.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/fixtures/responses.py b/tests/fixtures/responses.py index 29f978e..a9aaff7 100644 --- a/tests/fixtures/responses.py +++ b/tests/fixtures/responses.py @@ -28,8 +28,8 @@ from os import environ from pathlib import Path from typing import Any, ContextManager, Dict, Iterator, Optional, Union, Type -import importlib_resources as resources import pytest +from importlib_resources import as_file, files from pytest import FixtureRequest from requests import Session, Response from requests.sessions import PreparedRequest @@ -178,7 +178,8 @@ def responses(request: FixtureRequest) -> Iterator[Union[Recorder, Responder]]: """ real = environ.get('REAL_HTTP', '').lower() name = request.path.with_suffix('.json').name - package = request.module.__package__ + package = files(request.module.__package__) + resource = package.joinpath(name) context: Type[Union[Recorder, Responder]] @@ -187,6 +188,6 @@ def responses(request: FixtureRequest) -> Iterator[Union[Recorder, Responder]]: else: context = Responder - with resources.path(package, name) as path: + with as_file(resource) as path: with context(path) as handler: yield handler