1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 20:35:55 +00:00

Migrate to python 3.8 (#1824)

* Migrate to python 3.8

* Fix tests on Py38

* cleanup tests

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Pascal Vizeli
2020-07-13 22:26:41 +02:00
committed by GitHub
parent 7f4284f2af
commit bdfcf1a2df
13 changed files with 38 additions and 43 deletions

View File

@@ -7,20 +7,3 @@ def load_json_fixture(filename):
"""Load a fixture."""
path = Path(Path(__file__).parent.joinpath("fixtures"), filename)
return json.loads(path.read_text())
def mock_coro(return_value=None, exception=None):
"""Return a coro that returns a value or raise an exception."""
return mock_coro_func(return_value, exception)()
def mock_coro_func(return_value=None, exception=None):
"""Return a method to create a coro function that returns a value."""
async def coro(*args, **kwargs):
"""Fake coroutine."""
if exception:
raise exception
return return_value
return coro

View File

@@ -5,8 +5,6 @@ import pytest
from supervisor.bootstrap import initialize_coresys
from tests.common import mock_coro
# pylint: disable=redefined-outer-name
@@ -21,8 +19,7 @@ def docker():
async def coresys(loop, docker):
"""Create a CoreSys Mock."""
with patch("supervisor.bootstrap.initialize_system_data"), patch(
"supervisor.bootstrap.fetch_timezone",
return_value=mock_coro(return_value="Europe/Zurich"),
"supervisor.bootstrap.fetch_timezone", return_value="Europe/Zurich",
):
coresys_obj = await initialize_coresys()

View File

@@ -24,23 +24,23 @@ async def test_dns_url_v4_good():
assert supervisor.validate.dns_url(url)
async def test_dns_url_v6_good():
def test_dns_url_v6_good():
"""Test the DNS validator with known-good ipv6 DNS URLs."""
for url in GOOD_V6:
assert supervisor.validate.dns_url(url)
async def test_dns_server_list_v4():
def test_dns_server_list_v4():
"""Test a list with v4 addresses."""
assert supervisor.validate.dns_server_list(GOOD_V4)
async def test_dns_server_list_v6():
def test_dns_server_list_v6():
"""Test a list with v6 addresses."""
assert supervisor.validate.dns_server_list(GOOD_V6)
async def test_dns_server_list_combined():
def test_dns_server_list_combined():
"""Test a list with both v4 and v6 addresses."""
combined = GOOD_V4 + GOOD_V6
# test the matches
@@ -52,14 +52,14 @@ async def test_dns_server_list_combined():
supervisor.validate.dns_server_list(combined + combined + combined + combined)
async def test_dns_server_list_bad():
def test_dns_server_list_bad():
"""Test the bad list."""
# test the matches
with pytest.raises(voluptuous.error.Invalid):
assert supervisor.validate.dns_server_list(BAD)
async def test_dns_server_list_bad_combined():
def test_dns_server_list_bad_combined():
"""Test the bad list, combined with the good."""
combined = GOOD_V4 + GOOD_V6 + BAD