File: test_circular_imports.py

package info (click to toggle)
python-zeroconf 0.147.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,380 kB
  • sloc: python: 15,356; makefile: 23
file content (32 lines) | stat: -rw-r--r-- 853 bytes parent folder | download | duplicates (2)
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
"""Test to check for circular imports."""

from __future__ import annotations

import asyncio
import sys

import pytest


@pytest.mark.asyncio
@pytest.mark.timeout(30)  # cloud can take > 9s
@pytest.mark.parametrize(
    "module",
    [
        "zeroconf",
        "zeroconf.asyncio",
        "zeroconf._protocol.incoming",
        "zeroconf._protocol.outgoing",
        "zeroconf.const",
        "zeroconf._logger",
        "zeroconf._transport",
        "zeroconf._record_update",
        "zeroconf._services.browser",
        "zeroconf._services.info",
    ],
)
async def test_circular_imports(module: str) -> None:
    """Check that components can be imported without circular imports."""
    process = await asyncio.create_subprocess_exec(sys.executable, "-c", f"import {module}")
    await process.communicate()
    assert process.returncode == 0