mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Run tests on Python 3.6 (#5162)
* Run tests on Python 3.6 * Fix dsmr test * Fix async util tests * Fix rest sensor test
This commit is contained in:
parent
fdd3fa7d80
commit
9eed03108f
@ -12,6 +12,8 @@ matrix:
|
|||||||
env: TOXENV=typing
|
env: TOXENV=typing
|
||||||
- python: "3.5"
|
- python: "3.5"
|
||||||
env: TOXENV=py35
|
env: TOXENV=py35
|
||||||
|
- python: "3.6"
|
||||||
|
env: TOXENV=py36
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- python: "3.5"
|
- python: "3.5"
|
||||||
env: TOXENV=typing
|
env: TOXENV=typing
|
||||||
|
@ -11,7 +11,7 @@ from unittest.mock import Mock
|
|||||||
from homeassistant.bootstrap import async_setup_component
|
from homeassistant.bootstrap import async_setup_component
|
||||||
from homeassistant.components.sensor.dsmr import DerivativeDSMREntity
|
from homeassistant.components.sensor.dsmr import DerivativeDSMREntity
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
from homeassistant.const import STATE_UNKNOWN
|
||||||
from tests.common import assert_setup_component
|
from tests.common import assert_setup_component, mock_coro
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@ -35,7 +35,7 @@ def test_default_setup(hass, monkeypatch):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# mock for injecting DSMR telegram
|
# mock for injecting DSMR telegram
|
||||||
dsmr = Mock(return_value=Mock())
|
dsmr = Mock(return_value=mock_coro([Mock(), None]))
|
||||||
monkeypatch.setattr('dsmr_parser.protocol.create_dsmr_reader', dsmr)
|
monkeypatch.setattr('dsmr_parser.protocol.create_dsmr_reader', dsmr)
|
||||||
|
|
||||||
with assert_setup_component(1):
|
with assert_setup_component(1):
|
||||||
@ -66,6 +66,7 @@ def test_default_setup(hass, monkeypatch):
|
|||||||
assert power_tariff.attributes.get('unit_of_measurement') is None
|
assert power_tariff.attributes.get('unit_of_measurement') is None
|
||||||
|
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
def test_derivative():
|
def test_derivative():
|
||||||
"""Test calculation of derivative value."""
|
"""Test calculation of derivative value."""
|
||||||
from dsmr_parser.objects import MBusObject
|
from dsmr_parser.objects import MBusObject
|
||||||
|
@ -200,7 +200,7 @@ class TestRestData(unittest.TestCase):
|
|||||||
self.rest.update()
|
self.rest.update()
|
||||||
self.assertEqual('test data', self.rest.data)
|
self.assertEqual('test data', self.rest.data)
|
||||||
|
|
||||||
@patch('requests.get', side_effect=RequestException)
|
@patch('requests.Session', side_effect=RequestException)
|
||||||
def test_update_request_exception(self, mock_req):
|
def test_update_request_exception(self, mock_req):
|
||||||
"""Test update when a request exception occurs."""
|
"""Test update when a request exception occurs."""
|
||||||
self.rest.update()
|
self.rest.update()
|
||||||
|
@ -87,6 +87,7 @@ class RunCoroutineThreadsafeTests(test_utils.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Test setup method."""
|
"""Test setup method."""
|
||||||
|
super().setUp()
|
||||||
self.loop = asyncio.new_event_loop()
|
self.loop = asyncio.new_event_loop()
|
||||||
self.set_event_loop(self.loop) # Will cleanup properly
|
self.set_event_loop(self.loop) # Will cleanup properly
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user