mirror of
https://github.com/home-assistant/core
synced 2024-09-09 12:51:22 +02:00
![Jan Bouwhuis](/assets/img/avatar_default.png)
* 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>
30 lines
806 B
Python
30 lines
806 B
Python
"""Test test fixture configuration."""
|
|
import socket
|
|
|
|
import pytest
|
|
import pytest_socket
|
|
|
|
from homeassistant.core import async_get_hass
|
|
|
|
|
|
def test_sockets_disabled():
|
|
"""Test we can't open sockets."""
|
|
with pytest.raises(pytest_socket.SocketBlockedError):
|
|
socket.socket()
|
|
|
|
|
|
def test_sockets_enabled(socket_enabled):
|
|
"""Test we can't connect to an address different from 127.0.0.1."""
|
|
mysocket = socket.socket()
|
|
with pytest.raises(pytest_socket.SocketConnectBlockedError):
|
|
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
|