Fix more tests on Python 3.8 (#34703)
This commit is contained in:
1 parent
5760fb94fe
commit
e7f8d6bbf7
7 files changed
+34
-55
No files matched your search
@@ -1,12 +1,11 @@
|
||||
"""Test Home Assistant location util methods."""
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import aiohttp
|
||||
from asynctest import Mock, patch
|
||||
import pytest
|
||||
|
||||
import homeassistant.util.location as location_util
|
||||
|
||||
from tests.common import load_fixture, mock_coro
|
||||
from tests.common import load_fixture
|
||||
|
||||
# Paris
|
||||
COORDINATES_PARIS = (48.864716, 2.349014)
|
||||
@@ -109,7 +108,7 @@ async def test_detect_location_info_ip_api(aioclient_mock, session):
|
||||
"""Test detect location info using ip-api.com."""
|
||||
aioclient_mock.get(location_util.IP_API, text=load_fixture("ip-api.com.json"))
|
||||
|
||||
with patch("homeassistant.util.location._get_ipapi", return_value=mock_coro(None)):
|
||||
with patch("homeassistant.util.location._get_ipapi", return_value=None):
|
||||
info = await location_util.async_detect_location_info(session, _test_real=True)
|
||||
|
||||
assert info is not None
|
||||
@@ -128,9 +127,9 @@ async def test_detect_location_info_ip_api(aioclient_mock, session):
|
||||
|
||||
async def test_detect_location_info_both_queries_fail(session):
|
||||
"""Ensure we return None if both queries fail."""
|
||||
with patch(
|
||||
"homeassistant.util.location._get_ipapi", return_value=mock_coro(None)
|
||||
), patch("homeassistant.util.location._get_ip_api", return_value=mock_coro(None)):
|
||||
with patch("homeassistant.util.location._get_ipapi", return_value=None), patch(
|
||||
"homeassistant.util.location._get_ip_api", return_value=None
|
||||
):
|
||||
info = await location_util.async_detect_location_info(session, _test_real=True)
|
||||
assert info is None
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import logging
|
||||
import os
|
||||
from subprocess import PIPE
|
||||
import sys
|
||||
from unittest.mock import MagicMock, call, patch
|
||||
|
||||
from asynctest import MagicMock, call, patch
|
||||
import pkg_resources
|
||||
import pytest
|
||||
|
||||
|
||||
Reference in new issue
Block a user