From bf7aecce901ef4553892fc28e894cde4583a3c9b Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Thu, 2 Mar 2017 03:07:50 -0500 Subject: [PATCH] Use dynamic ports for test instances (#6232) --- tests/common.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tests/common.py b/tests/common.py index a1635e3387c..34cd9765695 100644 --- a/tests/common.py +++ b/tests/common.py @@ -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.