Skip to content

Commit e6d2352

Browse files
authored
[Corehttp] Refactor tests imports (Azure#33116)
This will allow whl_no_aio to still pass. Signed-off-by: Paul Van Eck <[email protected]>
1 parent aacafd9 commit e6d2352

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

sdk/core/corehttp/tests/utils.py

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,52 @@
88

99
############################## LISTS USED TO PARAMETERIZE TESTS ##############################
1010
from corehttp.rest import HttpRequest as RestHttpRequest
11-
from corehttp.transport.requests import RequestsTransport
12-
from corehttp.transport.httpx import HttpXTransport, AsyncHttpXTransport
13-
from corehttp.transport.aiohttp import AioHttpTransport
1411

1512

16-
SYNC_TRANSPORTS = [RequestsTransport, HttpXTransport]
17-
ASYNC_TRANSPORTS = [AioHttpTransport, AsyncHttpXTransport]
13+
SYNC_TRANSPORTS = []
14+
ASYNC_TRANSPORTS = []
1815

19-
HTTP_REQUESTS = [RestHttpRequest]
16+
AIOHTTP_TRANSPORT_RESPONSES = []
2017
REQUESTS_TRANSPORT_RESPONSES = []
2118

22-
from corehttp.rest._http_response_impl import HttpResponseImpl as RestHttpResponse
23-
24-
HTTP_RESPONSES = [RestHttpResponse]
19+
try:
20+
from corehttp.rest._requests_basic import RestRequestsTransportResponse
21+
from corehttp.transport.requests import RequestsTransport
2522

26-
ASYNC_HTTP_RESPONSES = []
23+
SYNC_TRANSPORTS.append(RequestsTransport)
24+
REQUESTS_TRANSPORT_RESPONSES = [RestRequestsTransportResponse]
25+
except (ImportError, SyntaxError):
26+
pass
2727

2828
try:
29-
from corehttp.rest._http_response_impl_async import AsyncHttpResponseImpl as RestAsyncHttpResponse
29+
from corehttp.rest._aiohttp import RestAioHttpTransportResponse
30+
from corehttp.transport.aiohttp import AioHttpTransport
3031

31-
ASYNC_HTTP_RESPONSES = [RestAsyncHttpResponse]
32+
ASYNC_TRANSPORTS.append(AioHttpTransport)
33+
AIOHTTP_TRANSPORT_RESPONSES = [RestAioHttpTransportResponse]
3234
except (ImportError, SyntaxError):
3335
pass
3436

3537
try:
36-
from corehttp.rest._requests_basic import RestRequestsTransportResponse
38+
from corehttp.transport.httpx import HttpXTransport, AsyncHttpXTransport
3739

38-
REQUESTS_TRANSPORT_RESPONSES = [RestRequestsTransportResponse]
39-
except ImportError:
40+
SYNC_TRANSPORTS.append(HttpXTransport)
41+
ASYNC_TRANSPORTS.append(AsyncHttpXTransport)
42+
except (ImportError, SyntaxError):
4043
pass
4144

42-
AIOHTTP_TRANSPORT_RESPONSES = []
45+
HTTP_REQUESTS = [RestHttpRequest]
46+
47+
from corehttp.rest._http_response_impl import HttpResponseImpl as RestHttpResponse
48+
49+
HTTP_RESPONSES = [RestHttpResponse]
50+
51+
ASYNC_HTTP_RESPONSES = []
4352

4453
try:
45-
from corehttp.rest._aiohttp import RestAioHttpTransportResponse
54+
from corehttp.rest._http_response_impl_async import AsyncHttpResponseImpl as RestAsyncHttpResponse
4655

47-
AIOHTTP_TRANSPORT_RESPONSES = [RestAioHttpTransportResponse]
56+
ASYNC_HTTP_RESPONSES = [RestAsyncHttpResponse]
4857
except (ImportError, SyntaxError):
4958
pass
5059

0 commit comments

Comments
 (0)