2020-07-18 17:35:13 +08:00
|
|
|
"""Test importing of all internal packages and modules.
|
2020-02-03 21:04:16 +08:00
|
|
|
|
|
|
|
This ensures all internal packages can be imported without needing the pytest
|
|
|
|
namespace being set, which is critical for the initialization of xdist.
|
|
|
|
"""
|
2019-10-02 04:24:23 +08:00
|
|
|
import pkgutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2020-04-09 22:56:01 +08:00
|
|
|
from typing import List
|
2019-10-02 04:24:23 +08:00
|
|
|
|
|
|
|
import _pytest
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2020-04-09 22:56:01 +08:00
|
|
|
def _modules() -> List[str]:
|
2020-10-06 09:13:05 +08:00
|
|
|
pytest_pkg: str = _pytest.__path__ # type: ignore
|
2019-10-02 04:24:23 +08:00
|
|
|
return sorted(
|
|
|
|
n
|
2020-04-09 22:56:01 +08:00
|
|
|
for _, n, _ in pkgutil.walk_packages(pytest_pkg, prefix=_pytest.__name__ + ".")
|
2019-10-02 04:24:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-10-23 05:44:16 +08:00
|
|
|
@pytest.mark.slow
|
2019-10-02 04:24:23 +08:00
|
|
|
@pytest.mark.parametrize("module", _modules())
|
2020-04-09 22:56:01 +08:00
|
|
|
def test_no_warnings(module: str) -> None:
|
2019-10-02 04:24:23 +08:00
|
|
|
# fmt: off
|
|
|
|
subprocess.check_call((
|
|
|
|
sys.executable,
|
|
|
|
"-W", "error",
|
2020-10-03 04:16:22 +08:00
|
|
|
"-c", f"__import__({module!r})",
|
2019-10-02 04:24:23 +08:00
|
|
|
))
|
|
|
|
# fmt: on
|