Add warning when testpaths is set but paths are not found by glob (#11044)

Closes #11013

---------

Co-authored-by: Ran Benita <ran@unusedvar.com>
This commit is contained in:
Kenny Y
2023-05-30 06:06:13 -04:00
committed by GitHub
parent fbfd4b5005
commit 7c231baa64
4 changed files with 25 additions and 0 deletions

View File

@@ -1382,6 +1382,15 @@ class Config:
args = []
for path in testpaths:
args.extend(sorted(glob.iglob(path, recursive=True)))
if testpaths and not args:
warning_text = (
"No files were found in testpaths; "
"consider removing or adjusting your testpaths configuration. "
"Searching recursively from the current directory instead."
)
self.issue_config_time_warning(
PytestConfigWarning(warning_text), stacklevel=3
)
if not args:
source = Config.ArgsSource.INCOVATION_DIR
args = [str(self.invocation_params.dir)]