Skip to content

Commit bb4ed1c

Browse files
committed
Improve async
1 parent a3ac401 commit bb4ed1c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/test_airos8.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import airos.exceptions
99
import pytest
1010

11+
import aiofiles
1112
import aiohttp
1213
from mashumaro.exceptions import MissingField
1314

@@ -277,8 +278,9 @@ async def test_warnings_correctly_parses_json() -> None:
277278
mock_response = MagicMock()
278279
mock_response.__aenter__.return_value = mock_response
279280
mock_response.status = 200
280-
with open("fixtures/warnings.json", encoding="utf-8") as f:
281-
mock_response_data = json.load(f)
281+
async with aiofiles.open("fixtures/warnings.json") as f:
282+
content = await f.read()
283+
mock_response_data = json.loads(content)
282284
mock_response.text = AsyncMock(return_value=json.dumps(mock_response_data))
283285

284286
with patch.object(airos_device.session, "get", return_value=mock_response):
@@ -327,8 +329,9 @@ async def test_update_check_correctly_parses_json() -> None:
327329
mock_response = MagicMock()
328330
mock_response.__aenter__.return_value = mock_response
329331
mock_response.status = 200
330-
with open("fixtures/update_check_available.json", encoding="utf-8") as f:
331-
mock_response_data = json.load(f)
332+
async with aiofiles.open("fixtures/update_check_available.json") as f:
333+
content = await f.read()
334+
mock_response_data = json.loads(content)
332335
mock_response.text = AsyncMock(return_value=json.dumps(mock_response_data))
333336

334337
with patch.object(airos_device.session, "post", return_value=mock_response):

0 commit comments

Comments
 (0)