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 ] :
pytest_pkg = _pytest . __path__ # type: str # 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 " ,
# https://github.com/pytest-dev/pytest/issues/5901
" -W " , " ignore:The usage of `cmp` is deprecated and will be removed on or after 2021-06-01. Please use `eq` and `order` instead.:DeprecationWarning " , # noqa: E501
2020-04-09 22:56:01 +08:00
" -c " , " __import__( {!r} ) " . format ( module ) ,
2019-10-02 04:24:23 +08:00
) )
# fmt: on