Clean up some Python 3.4 remnants (#14433)

pull/14448/head
Ville Skyttä 2018-05-13 17:56:42 +02:00 committed by Pascal Vizeli
parent e5d714ef52
commit 146a9492ec
2 changed files with 3 additions and 11 deletions

View File

@ -126,11 +126,7 @@ class LogErrorHandler(logging.Handler):
if record.levelno >= logging.WARN:
stack = []
if not record.exc_info:
try:
stack = [f for f, _, _, _ in traceback.extract_stack()]
except ValueError:
# On Python 3.4 under py.test getting the stack might fail.
pass
stack = [f for f, _, _, _ in traceback.extract_stack()]
entry = self._create_entry(record, stack)
self.records.appendleft(entry)

View File

@ -2,10 +2,6 @@
import asyncio
from unittest import mock
# Using third party package because of a bug reading binary data in Python 3.4
# https://bugs.python.org/issue23004
from mock_open import MockOpen
from homeassistant.components.camera import DOMAIN
from homeassistant.components.camera.local_file import (
SERVICE_UPDATE_FILE_PATH)
@ -30,7 +26,7 @@ def test_loading_file(hass, aiohttp_client):
client = yield from aiohttp_client(hass.http.app)
m_open = MockOpen(read_data=b'hello')
m_open = mock.mock_open(read_data=b'hello')
with mock.patch(
'homeassistant.components.camera.local_file.open',
m_open, create=True
@ -90,7 +86,7 @@ def test_camera_content_type(hass, aiohttp_client):
client = yield from aiohttp_client(hass.http.app)
image = 'hello'
m_open = MockOpen(read_data=image.encode())
m_open = mock.mock_open(read_data=image.encode())
with mock.patch('homeassistant.components.camera.local_file.open',
m_open, create=True):
resp_1 = yield from client.get('/api/camera_proxy/camera.test_jpg')