Issue warning/error if 'testpaths' does not match any files/folders #11013
Labels
good first issue
easy issue that is friendly to new contributor
topic: config
related to config handling, argument parsing and config file
We should issue a warning (or even an error?) if
testpaths
does not match any files or folders.I think an error is reasonable, even if it might break some incorrectly-configured suite out there.
Originally posted by @nicoddemus in #11006 (comment)
This is not really a bug, but an intended (albeit questionable) behavior:
The values of
testpaths
are actually globs, so globbing fortests
in the root yields nothing. Given it finds nothing, pytest will behave as if called from the command-line without any parameters, which makes it search recursively from the current directory looking forpython_files
to collect.pytest/src/_pytest/config/__init__.py
Lines 1382 to 1384 in 739408b
If you create the
tests
directory, then pytest will correctly search in that directory only.I agree those 2 facts are surprising:
testpaths
is a glob. This is documented but easy to overlook, probably we should add a glob to the example there.I don't think we can do anything more for 1, but for 2 seems like we should at least emit a warning if
testpaths
is defined but does not match anything.The text was updated successfully, but these errors were encountered: