Skip to content

Commit 7c37ef0

Browse files
committed
Update test to be compliant with new Pytest version
1 parent 4da45df commit 7c37ef0

File tree

2 files changed

+5
-1270
lines changed

2 files changed

+5
-1270
lines changed

tests/unit/test_client_errors.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import json
2+
from collections.abc import Generator
23

34
import httpx
45
import pytest
56
import respx
6-
from respx import MockRouter
77

88
from apify_client._errors import ApifyApiError
99
from apify_client._http_client import HTTPClient, HTTPClientAsync
@@ -16,13 +16,14 @@
1616
}
1717

1818

19-
@respx.mock
2019
@pytest.fixture(autouse=True)
21-
def mocked_response(respx_mock: MockRouter) -> None:
20+
def mocked_response() -> Generator[respx.router.MockRouter]:
2221
response_content = json.dumps(
2322
{'error': {'message': _EXPECTED_MESSAGE, 'type': _EXPECTED_TYPE, 'data': _EXPECTED_DATA}}
2423
)
25-
respx_mock.get(_TEST_URL).mock(return_value=httpx.Response(400, content=response_content))
24+
with respx.mock() as respx_mock:
25+
respx_mock.get(_TEST_URL).mock(return_value=httpx.Response(400, content=response_content))
26+
yield respx_mock
2627

2728

2829
def test_client_apify_api_error_with_data() -> None:

0 commit comments

Comments
 (0)