Fix test_no_warnings to handle e.g. `_pytest.async` (#7044)
Before this patch it would result in a SyntaxError with e.g. `import _pytest.async`.
This commit is contained in:
parent
413ca8a4d0
commit
f136b79f1a
|
@ -7,29 +7,29 @@ namespace being set, which is critical for the initialization of xdist.
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import _pytest
|
import _pytest
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
def _modules():
|
def _modules() -> List[str]:
|
||||||
|
pytest_pkg = _pytest.__path__ # type: str # type: ignore
|
||||||
return sorted(
|
return sorted(
|
||||||
n
|
n
|
||||||
for _, n, _ in pkgutil.walk_packages(
|
for _, n, _ in pkgutil.walk_packages(pytest_pkg, prefix=_pytest.__name__ + ".")
|
||||||
_pytest.__path__, prefix=_pytest.__name__ + "."
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
@pytest.mark.slow
|
||||||
@pytest.mark.parametrize("module", _modules())
|
@pytest.mark.parametrize("module", _modules())
|
||||||
def test_no_warnings(module):
|
def test_no_warnings(module: str) -> None:
|
||||||
# fmt: off
|
# fmt: off
|
||||||
subprocess.check_call((
|
subprocess.check_call((
|
||||||
sys.executable,
|
sys.executable,
|
||||||
"-W", "error",
|
"-W", "error",
|
||||||
# https://github.com/pytest-dev/pytest/issues/5901
|
# 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
|
"-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
|
||||||
"-c", "import {}".format(module),
|
"-c", "__import__({!r})".format(module),
|
||||||
))
|
))
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
Loading…
Reference in New Issue