File tree Expand file tree Collapse file tree 5 files changed +45
-6
lines changed
Expand file tree Collapse file tree 5 files changed +45
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ verify_ssl = true
55
66[dev-packages ]
77async-asgi-testclient = " *"
8+ async_generator = " *"
9+ asyncmock = " *"
810bandit = " *"
911black = " ==19.10b0"
1012coveralls = " *"
Original file line number Diff line number Diff line change 33from datetime import datetime
44
55from asyncache import cached
6+
67from cachetools import TTLCache
78
89from ...coordinates import Coordinates
Original file line number Diff line number Diff line change 33from datetime import datetime
44
55from asyncache import cached
6+
67from cachetools import TTLCache
78
89from ...coordinates import Coordinates
Original file line number Diff line number Diff line change 55"""
66import datetime
77import os
8- from contextlib import asynccontextmanager
9- from unittest import mock
108
119import pytest
1210from async_asgi_testclient import TestClient as AsyncTestClient
13- from fastapi .testclient import TestClient
1411
1512from app .main import APP
1613from app .utils import httputils
14+ from fastapi .testclient import TestClient
15+
16+ try :
17+ from unittest .mock import AsyncMock
18+ except ImportError :
19+ # Python 3.7 backwards compat
20+ from asyncmock import AsyncMock
21+
22+ try :
23+ from contextlib import asynccontextmanager
24+ except ImportError :
25+ # Python 3.6 backwards compat
26+ from async_generator import asynccontextmanager
27+
28+
1729
1830
1931@pytest .fixture
@@ -80,7 +92,7 @@ def mock_client_session_class(request):
8092 See: https://docs.pytest.org/en/5.4.1/unittest.html#mixing-pytest-fixtures-into-unittest-testcase-subclasses-using-marks
8193 """
8294
83- httputils .CLIENT_SESSION = request .cls .mock_client_session = mock . AsyncMock ()
95+ httputils .CLIENT_SESSION = request .cls .mock_client_session = AsyncMock ()
8496 httputils .CLIENT_SESSION .get = mocked_session_get
8597 try :
8698 yield
@@ -94,7 +106,7 @@ async def mock_client_session():
94106 instance.
95107 """
96108
97- httputils .CLIENT_SESSION = mock . AsyncMock ()
109+ httputils .CLIENT_SESSION = AsyncMock ()
98110 httputils .CLIENT_SESSION .get = mocked_session_get
99111 try :
100112 yield httputils .CLIENT_SESSION
You can’t perform that action at this time.
0 commit comments