mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use dynamic ports for test instances (#6232)
This commit is contained in:
parent
e2aa024a05
commit
bf7aecce90
@ -10,6 +10,7 @@ import threading
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from aiohttp.test_utils import unused_port as get_test_instance_port # noqa
|
||||||
|
|
||||||
from homeassistant import core as ha, loader
|
from homeassistant import core as ha, loader
|
||||||
from homeassistant.bootstrap import setup_component, DATA_SETUP
|
from homeassistant.bootstrap import setup_component, DATA_SETUP
|
||||||
@ -23,7 +24,7 @@ import homeassistant.util.yaml as yaml
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME, EVENT_TIME_CHANGED,
|
STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME, EVENT_TIME_CHANGED,
|
||||||
EVENT_STATE_CHANGED, EVENT_PLATFORM_DISCOVERED, ATTR_SERVICE,
|
EVENT_STATE_CHANGED, EVENT_PLATFORM_DISCOVERED, ATTR_SERVICE,
|
||||||
ATTR_DISCOVERED, SERVER_PORT, EVENT_HOMEASSISTANT_STOP)
|
ATTR_DISCOVERED, EVENT_HOMEASSISTANT_STOP)
|
||||||
from homeassistant.components import sun, mqtt, recorder
|
from homeassistant.components import sun, mqtt, recorder
|
||||||
from homeassistant.components.http.auth import auth_middleware
|
from homeassistant.components.http.auth import auth_middleware
|
||||||
from homeassistant.components.http.const import (
|
from homeassistant.components.http.const import (
|
||||||
@ -31,7 +32,6 @@ from homeassistant.components.http.const import (
|
|||||||
from homeassistant.util.async import (
|
from homeassistant.util.async import (
|
||||||
run_callback_threadsafe, run_coroutine_threadsafe)
|
run_callback_threadsafe, run_coroutine_threadsafe)
|
||||||
|
|
||||||
_TEST_INSTANCE_PORT = SERVER_PORT
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
INST_COUNT = 0
|
INST_COUNT = 0
|
||||||
|
|
||||||
@ -139,18 +139,6 @@ def async_test_home_assistant(loop):
|
|||||||
return hass
|
return hass
|
||||||
|
|
||||||
|
|
||||||
def get_test_instance_port():
|
|
||||||
"""Return unused port for running test instance.
|
|
||||||
|
|
||||||
The socket that holds the default port does not get released when we stop
|
|
||||||
HA in a different test case. Until I have figured out what is going on,
|
|
||||||
let's run each test on a different port.
|
|
||||||
"""
|
|
||||||
global _TEST_INSTANCE_PORT
|
|
||||||
_TEST_INSTANCE_PORT += 1
|
|
||||||
return _TEST_INSTANCE_PORT
|
|
||||||
|
|
||||||
|
|
||||||
def mock_service(hass, domain, service):
|
def mock_service(hass, domain, service):
|
||||||
"""Setup a fake service.
|
"""Setup a fake service.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user