Debian Codegraph @

testing/test_meta.py

raw
1 """Test importing of all internal packages and modules.
2
3 This ensures all internal packages can be imported without needing the pytest
4 namespace being set, which is critical for the initialization of xdist.
5 """
6
7 from __future__ import annotations
8
9 import pkgutil
10 import subprocess
11 import sys
12
13 import _pytest
14 import pytest
15
16
17 def _modules() -> list[str]:
18 pytest_pkg: str = _pytest.__path__ # type: ignore
19 return sorted(
20 n
21 for _, n, _ in pkgutil.walk_packages(pytest_pkg, prefix=_pytest.__name__ + ".")
22 )
23
24
25 @pytest.mark.slow
26 @pytest.mark.parametrize("module", _modules())
27 def test_no_warnings(module: str) -> None:
28 # fmt: off
29 subprocess.check_call((
30 sys.executable,
31 "-W", "error",
32 "-c", f"__import__({module!r})",
33 ))
34 # fmt: on