diff --git a/tests/__init__.py b/tests/__init__.py index e582287f941..1f18116b24b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -6,6 +6,7 @@ Tests initialization. """ import betamax +from homeassistant import util from homeassistant.util import location with betamax.Betamax.configure() as config: @@ -28,3 +29,4 @@ location.detect_location_info = lambda: location.LocationInfo( ) location.elevation = lambda latitude, longitude: 0 +util.get_local_ip = lambda: '127.0.0.1' diff --git a/tests/components/device_tracker/test_locative.py b/tests/components/device_tracker/test_locative.py index 32a63d0962f..5182a536034 100644 --- a/tests/components/device_tracker/test_locative.py +++ b/tests/components/device_tracker/test_locative.py @@ -28,9 +28,7 @@ def _url(data={}): return "{}{}locative?{}".format(HTTP_BASE_URL, const.URL_API, data) -@patch('homeassistant.components.http.util.get_local_ip', - return_value='127.0.0.1') -def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name +def setUpModule(): # pylint: disable=invalid-name """ Initalizes a Home Assistant server. """ global hass diff --git a/tests/components/test_alexa.py b/tests/components/test_alexa.py index fa08f8e9129..f1de566a57e 100644 --- a/tests/components/test_alexa.py +++ b/tests/components/test_alexa.py @@ -7,7 +7,6 @@ Tests Home Assistant Alexa component does what it should do. # pylint: disable=protected-access,too-many-public-methods import unittest import json -from unittest.mock import patch import requests @@ -29,9 +28,7 @@ hass = None calls = [] -@patch('homeassistant.components.http.util.get_local_ip', - return_value='127.0.0.1') -def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name +def setUpModule(): # pylint: disable=invalid-name """ Initalize a Home Assistant server for testing this module. """ global hass diff --git a/tests/components/test_api.py b/tests/components/test_api.py index 6e72666454f..3dbaedd8c1a 100644 --- a/tests/components/test_api.py +++ b/tests/components/test_api.py @@ -32,9 +32,7 @@ def _url(path=""): return HTTP_BASE_URL + path -@patch('homeassistant.components.http.util.get_local_ip', - return_value='127.0.0.1') -def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name +def setUpModule(): # pylint: disable=invalid-name """ Initializes a Home Assistant server. """ global hass diff --git a/tests/components/test_frontend.py b/tests/components/test_frontend.py index a81cea899f6..8455bd5a8f9 100644 --- a/tests/components/test_frontend.py +++ b/tests/components/test_frontend.py @@ -7,7 +7,6 @@ Tests Home Assistant HTTP component does what it should do. # pylint: disable=protected-access,too-many-public-methods import re import unittest -from unittest.mock import patch import requests @@ -30,9 +29,7 @@ def _url(path=""): return HTTP_BASE_URL + path -@patch('homeassistant.components.http.util.get_local_ip', - return_value='127.0.0.1') -def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name +def setUpModule(): # pylint: disable=invalid-name """ Initalizes a Home Assistant server. """ global hass diff --git a/tests/test_remote.py b/tests/test_remote.py index 725ba25ac80..435cbde79f9 100644 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -6,7 +6,6 @@ Tests Home Assistant remote methods and classes. """ # pylint: disable=protected-access,too-many-public-methods import unittest -from unittest.mock import patch import homeassistant.core as ha import homeassistant.bootstrap as bootstrap @@ -24,7 +23,8 @@ HTTP_BASE_URL = "http://127.0.0.1:{}".format(MASTER_PORT) HA_HEADERS = {HTTP_HEADER_HA_AUTH: API_PASSWORD} -hass, slave, master_api, broken_api = None, None, None, None +broken_api = remote.API('127.0.0.1', BROKEN_PORT) +hass, slave, master_api = None, None, None def _url(path=""): @@ -32,9 +32,7 @@ def _url(path=""): return HTTP_BASE_URL + path -@patch('homeassistant.components.http.util.get_local_ip', - return_value='127.0.0.1') -def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name +def setUpModule(): # pylint: disable=invalid-name """ Initalizes a Home Assistant server and Slave instance. """ global hass, slave, master_api, broken_api @@ -63,9 +61,6 @@ def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name slave.start() - # Setup API pointing at nothing - broken_api = remote.API("127.0.0.1", "", BROKEN_PORT) - def tearDownModule(): # pylint: disable=invalid-name """ Stops the Home Assistant server and slave. """