Add warning when testpaths is set but paths are not found by glob

This commit is contained in:
Kenny Y 2023-05-27 19:14:53 -04:00
parent 4f3f36c396
commit 14d1d950cd
No known key found for this signature in database
GPG Key ID: 6048F488EF01A7F1
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1 @@
Added warning when testpaths is set, but paths are not found by glob. In this case, pytest will search fall back to searching from current directory.

View File

@ -1382,6 +1382,14 @@ class Config:
args = [] args = []
for path in testpaths: for path in testpaths:
args.extend(sorted(glob.iglob(path, recursive=True))) args.extend(sorted(glob.iglob(path, recursive=True)))
if testpaths and not args:
warning_text = (
"testpaths defined but path not found, "
"will search recursively from current directory instead"
)
self.issue_config_time_warning(
PytestConfigWarning(warning_text), stacklevel=3
)
if not args: if not args:
source = Config.ArgsSource.INCOVATION_DIR source = Config.ArgsSource.INCOVATION_DIR
args = [str(self.invocation_params.dir)] args = [str(self.invocation_params.dir)]