diff options
author | Ran Benita <ran@unusedvar.com> | 2020-08-23 12:05:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-23 12:05:22 +0300 |
commit | 837687c21a82c36dcd290a04fd8ff3b93b626e63 (patch) | |
tree | 9bed5a40b9d8685dd026b8bfa3c4bb122773ae3a /src | |
parent | 75af2bfa06436752165df884d4666402529b1d6a (diff) | |
parent | 5e39cd5e71cb624dd5c3bf823a3c9168be3f0ff3 (diff) | |
download | pytest-837687c21a82c36dcd290a04fd8ff3b93b626e63.tar.gz |
Merge pull request #7668 from bluetech/dir-match-msg
main: improve message on `pytest path/to/a/directory::mytest`
Diffstat (limited to 'src')
-rw-r--r-- | src/_pytest/main.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 2abfffba0..7ff362c34 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -808,6 +808,7 @@ def resolve_collection_argument( found module. If the path doesn't exist, raise UsageError. + If the path is a directory and selection parts are present, raise UsageError. """ strpath, *parts = str(arg).split("::") if as_pypath: @@ -821,4 +822,11 @@ def resolve_collection_argument( else "file or directory not found: {arg}" ) raise UsageError(msg.format(arg=arg)) + if parts and fspath.is_dir(): + msg = ( + "package argument cannot contain :: selection parts: {arg}" + if as_pypath + else "directory argument cannot contain :: selection parts: {arg}" + ) + raise UsageError(msg.format(arg=arg)) return py.path.local(str(fspath)), parts |