Use dynamic ports for test instances (#6232)
This commit is contained in:
parent
e2aa024a05
commit
bf7aecce90
1 changed files with 2 additions and 14 deletions
|
@ -10,6 +10,7 @@ import threading
|
|||
from contextlib import contextmanager
|
||||
|
||||
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.bootstrap import setup_component, DATA_SETUP
|
||||
|
@ -23,7 +24,7 @@ import homeassistant.util.yaml as yaml
|
|||
from homeassistant.const import (
|
||||
STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME, EVENT_TIME_CHANGED,
|
||||
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.http.auth import auth_middleware
|
||||
from homeassistant.components.http.const import (
|
||||
|
@ -31,7 +32,6 @@ from homeassistant.components.http.const import (
|
|||
from homeassistant.util.async import (
|
||||
run_callback_threadsafe, run_coroutine_threadsafe)
|
||||
|
||||
_TEST_INSTANCE_PORT = SERVER_PORT
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
INST_COUNT = 0
|
||||
|
||||
|
@ -139,18 +139,6 @@ def async_test_home_assistant(loop):
|
|||
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):
|
||||
"""Setup a fake service.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue