From adb15286b489fc83ff307e75e2de753b1dfc7dc2 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 23 Oct 2019 01:13:34 +0200 Subject: [PATCH] Fix test coverage, reverting top level import ptvsd (#28118) --- homeassistant/components/ptvsd/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/ptvsd/__init__.py b/homeassistant/components/ptvsd/__init__.py index f12c8004774..55cef1405d9 100644 --- a/homeassistant/components/ptvsd/__init__.py +++ b/homeassistant/components/ptvsd/__init__.py @@ -8,7 +8,6 @@ from asyncio import Event import logging from threading import Thread -import ptvsd import voluptuous as vol from homeassistant.const import CONF_HOST, CONF_PORT @@ -37,6 +36,12 @@ CONFIG_SCHEMA = vol.Schema( async def async_setup(hass: HomeAssistantType, config: ConfigType): """Set up ptvsd debugger.""" + + # This is a local import, since importing this at the top, will cause + # ptvsd to hook into `sys.settrace`. So does `coverage` to generate + # coverage, resulting in a battle and incomplete code test coverage. + import ptvsd # pylint: disable=import-outside-toplevel + conf = config[DOMAIN] host = conf[CONF_HOST] port = conf[CONF_PORT]