Restructure tests to ensure unique ports

This commit is contained in:
Paulus Schoutsen committed 2016-02-14 12:54:16 -08:00
1 parent 64430f26f3
commit dd2aec0a08
7 files changed
+97 -75

No files matched your search

+15 -1
View File
@@ -13,9 +13,11 @@ from homeassistant.helpers.entity import ToggleEntity
from homeassistant.const import (
STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME, EVENT_TIME_CHANGED,
EVENT_STATE_CHANGED, EVENT_PLATFORM_DISCOVERED, ATTR_SERVICE,
ATTR_DISCOVERED)
ATTR_DISCOVERED, SERVER_PORT)
from homeassistant.components import sun, mqtt
_TEST_INSTANCE_PORT = SERVER_PORT
def get_test_config_dir():
""" Returns a path to a test config dir. """
@@ -43,6 +45,18 @@ def get_test_home_assistant(num_threads=None):
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):
"""
Sets up a fake service.