forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_circular_imports.py
40 lines (35 loc) · 1.04 KB
/
test_circular_imports.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Test to check for circular imports in core components."""
import asyncio
import sys
import pytest
from homeassistant.bootstrap import (
CORE_INTEGRATIONS,
DEBUGGER_INTEGRATIONS,
DEFAULT_INTEGRATIONS,
FRONTEND_INTEGRATIONS,
LOGGING_AND_HTTP_DEPS_INTEGRATIONS,
RECORDER_INTEGRATIONS,
STAGE_1_INTEGRATIONS,
)
@pytest.mark.timeout(30) # cloud can take > 9s
@pytest.mark.parametrize(
"component",
sorted(
{
*DEBUGGER_INTEGRATIONS,
*CORE_INTEGRATIONS,
*LOGGING_AND_HTTP_DEPS_INTEGRATIONS,
*FRONTEND_INTEGRATIONS,
*RECORDER_INTEGRATIONS,
*STAGE_1_INTEGRATIONS,
*DEFAULT_INTEGRATIONS,
}
),
)
async def test_circular_imports(component: str) -> None:
"""Check that components can be imported without circular imports."""
process = await asyncio.create_subprocess_exec(
sys.executable, "-c", f"import homeassistant.components.{component}"
)
await process.communicate()
assert process.returncode == 0