def pytest_runtest_setup(): # Restrict all socket calls in order to prevent unintended web traffic during test runs. Use # @pytest.mark.enable_socket to enable socket connections on a per-test basis, or # @pytest.mark.allow_hosts(['<ip address>]) to allow connections to specific hosts. # # See: https://github.com/miketheman/pytest-socket for details. socket_allow_hosts(allowed=["localhost", "127.0.0.1", "::1"])
def pytest_runtest_setup(): """Throw if tests attempt to open sockets. allow_unix_socket is set to True because it's needed by asyncio. Important: socket_allow_hosts must be called before disable_socket, otherwise all destinations will be allowed. """ pytest_socket.socket_allow_hosts(["127.0.0.1"]) disable_socket(allow_unix_socket=True)
def pytest_runtest_setup(): """Prepare pytest_socket and freezegun. pytest_socket: Throw if tests attempt to open sockets. allow_unix_socket is set to True because it's needed by asyncio. Important: socket_allow_hosts must be called before disable_socket, otherwise all destinations will be allowed. freezegun: Modified to include https://github.com/spulec/freezegun/pull/424 """ pytest_socket.socket_allow_hosts(["127.0.0.1"]) disable_socket(allow_unix_socket=True) freezegun.api.datetime_to_fakedatetime = ha_datetime_to_fakedatetime freezegun.api.FakeDatetime = HAFakeDatetime
def pytest_runtest_setup(): socket_allow_hosts(['127.0.0.1', '::1'])
def pytest_runtest_setup(): pytest_socket.socket_allow_hosts(["127.0.0.1", None])