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,7 +1,7 @@
|
||||
"""Test the Home Assistant local auth provider."""
|
||||
import asyncio
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from asynctest import Mock, patch
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
@@ -12,8 +12,6 @@ from homeassistant.auth.providers import (
|
||||
homeassistant as hass_auth,
|
||||
)
|
||||
|
||||
from tests.common import mock_coro
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def data(hass):
|
||||
@@ -156,9 +154,7 @@ async def test_get_or_create_credentials(hass, data):
|
||||
provider = manager.auth_providers[0]
|
||||
provider.data = data
|
||||
credentials1 = await provider.async_get_or_create_credentials({"username": "hello"})
|
||||
with patch.object(
|
||||
provider, "async_credentials", return_value=mock_coro([credentials1])
|
||||
):
|
||||
with patch.object(provider, "async_credentials", return_value=[credentials1]):
|
||||
credentials2 = await provider.async_get_or_create_credentials(
|
||||
{"username": "hello "}
|
||||
)
|
||||
@@ -264,17 +260,13 @@ async def test_legacy_get_or_create_credentials(hass, legacy_data):
|
||||
provider.data = legacy_data
|
||||
credentials1 = await provider.async_get_or_create_credentials({"username": "hello"})
|
||||
|
||||
with patch.object(
|
||||
provider, "async_credentials", return_value=mock_coro([credentials1])
|
||||
):
|
||||
with patch.object(provider, "async_credentials", return_value=[credentials1]):
|
||||
credentials2 = await provider.async_get_or_create_credentials(
|
||||
{"username": "hello"}
|
||||
)
|
||||
assert credentials1 is credentials2
|
||||
|
||||
with patch.object(
|
||||
provider, "async_credentials", return_value=mock_coro([credentials1])
|
||||
):
|
||||
with patch.object(provider, "async_credentials", return_value=[credentials1]):
|
||||
credentials3 = await provider.async_get_or_create_credentials(
|
||||
{"username": "hello "}
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user