Merge pull request #4045 from nicoddemus/root-conftest-warning-workaround-4039

Do not issue non-top-level conftest warning when --pyargs is used
This commit is contained in:
Bruno Oliveira
2018-09-27 09:26:11 -03:00
committed by GitHub
4 changed files with 42 additions and 15 deletions

View File

@@ -351,6 +351,7 @@ class PytestPluginManager(PluginManager):
else None
)
self._noconftest = namespace.noconftest
self._using_pyargs = namespace.pyargs
testpaths = namespace.file_or_dir
foundanchor = False
for path in testpaths:
@@ -416,7 +417,11 @@ class PytestPluginManager(PluginManager):
_ensure_removed_sysmodule(conftestpath.purebasename)
try:
mod = conftestpath.pyimport()
if hasattr(mod, "pytest_plugins") and self._configured:
if (
hasattr(mod, "pytest_plugins")
and self._configured
and not self._using_pyargs
):
from _pytest.deprecated import (
PYTEST_PLUGINS_FROM_NON_TOP_LEVEL_CONFTEST
)