File tree Expand file tree Collapse file tree 2 files changed +5
-1270
lines changed Expand file tree Collapse file tree 2 files changed +5
-1270
lines changed Original file line number Diff line number Diff line change 1
1
import json
2
+ from collections .abc import Generator
2
3
3
4
import httpx
4
5
import pytest
5
6
import respx
6
- from respx import MockRouter
7
7
8
8
from apify_client ._errors import ApifyApiError
9
9
from apify_client ._http_client import HTTPClient , HTTPClientAsync
16
16
}
17
17
18
18
19
- @respx .mock
20
19
@pytest .fixture (autouse = True )
21
- def mocked_response (respx_mock : MockRouter ) -> None :
20
+ def mocked_response () -> Generator [ respx . router . MockRouter ] :
22
21
response_content = json .dumps (
23
22
{'error' : {'message' : _EXPECTED_MESSAGE , 'type' : _EXPECTED_TYPE , 'data' : _EXPECTED_DATA }}
24
23
)
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
26
27
27
28
28
29
def test_client_apify_api_error_with_data () -> None :
You can’t perform that action at this time.
0 commit comments