Set cv hass in hass fixture (#77271)
* Set cv hass in hass fixture * Move test_hass_cv and update docstring * Update tests/test_test_fixtures.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
ad6beac535
commit
7fc294d9b1
2 changed files with 13 additions and 0 deletions
|
@ -329,6 +329,8 @@ def hass(loop, load_registries, hass_storage, request):
|
||||||
|
|
||||||
exceptions = []
|
exceptions = []
|
||||||
hass = loop.run_until_complete(async_test_home_assistant(loop, load_registries))
|
hass = loop.run_until_complete(async_test_home_assistant(loop, load_registries))
|
||||||
|
ha._cv_hass.set(hass)
|
||||||
|
|
||||||
orig_exception_handler = loop.get_exception_handler()
|
orig_exception_handler = loop.get_exception_handler()
|
||||||
loop.set_exception_handler(exc_handle)
|
loop.set_exception_handler(exc_handle)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import socket
|
||||||
import pytest
|
import pytest
|
||||||
import pytest_socket
|
import pytest_socket
|
||||||
|
|
||||||
|
from homeassistant.core import async_get_hass
|
||||||
|
|
||||||
|
|
||||||
def test_sockets_disabled():
|
def test_sockets_disabled():
|
||||||
"""Test we can't open sockets."""
|
"""Test we can't open sockets."""
|
||||||
|
@ -16,3 +18,12 @@ def test_sockets_enabled(socket_enabled):
|
||||||
mysocket = socket.socket()
|
mysocket = socket.socket()
|
||||||
with pytest.raises(pytest_socket.SocketConnectBlockedError):
|
with pytest.raises(pytest_socket.SocketConnectBlockedError):
|
||||||
mysocket.connect(("127.0.0.2", 1234))
|
mysocket.connect(("127.0.0.2", 1234))
|
||||||
|
|
||||||
|
|
||||||
|
async def test_hass_cv(hass):
|
||||||
|
"""Test hass context variable.
|
||||||
|
|
||||||
|
When tests are using the `hass`, this tests that the hass context variable was set
|
||||||
|
in the fixture and that async_get_hass() works correctly.
|
||||||
|
"""
|
||||||
|
assert async_get_hass() is hass
|
||||||
|
|
Loading…
Add table
Reference in a new issue