1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- from unittest import mock
16- try :
15+ import sys
16+ if sys .version_info >= (3 , 8 ):
17+ from unittest import mock
1718 from unittest .mock import AsyncMock
18- except ImportError :
19- from mock import AsyncMock
19+ else :
20+ import mock
21+
22+ try :
23+ from mock import AsyncMock
24+ except ImportError :
25+ from asyncmock import AsyncMock
2026
2127import aiohttp # type: ignore
2228from aioresponses import aioresponses , core # type: ignore
@@ -44,7 +50,7 @@ def test__is_compressed_not(self):
4450
4551 @pytest .mark .asyncio
4652 async def test_raw_content (self ):
47- mock_response = mock . AsyncMock ()
53+ mock_response = AsyncMock ()
4854 mock_response .content .read .return_value = mock .sentinel .read
4955 combined_response = aiohttp_requests ._CombinedResponse (response = mock_response )
5056 raw_content = await combined_response .raw_content ()
@@ -57,7 +63,7 @@ async def test_raw_content(self):
5763
5864 @pytest .mark .asyncio
5965 async def test_content (self ):
60- mock_response = mock . AsyncMock ()
66+ mock_response = AsyncMock ()
6167 mock_response .content .read .return_value = mock .sentinel .read
6268 combined_response = aiohttp_requests ._CombinedResponse (response = mock_response )
6369 content = await combined_response .content ()
@@ -104,7 +110,7 @@ async def test_status_prop(self):
104110
105111 @pytest .mark .asyncio
106112 async def test_data_prop (self ):
107- mock_response = mock . AsyncMock ()
113+ mock_response = AsyncMock ()
108114 mock_response .content .read .return_value = mock .sentinel .read
109115 response = aiohttp_requests ._Response (mock_response )
110116 data = await response .data .read ()
0 commit comments