drop resolve_collection_argument cosmetic change

add more test cases for resolve_collection_argument
This commit is contained in:
Abdelrahman Elbehery 2022-09-24 23:22:16 +02:00
parent 7d192afeaf
commit 2b4563d77a
2 changed files with 12 additions and 1 deletions

View File

@ -886,7 +886,8 @@ def resolve_collection_argument(
parts[-1] = f"{parts[-1]}{squacket}{rest}"
if as_pypath:
strpath = search_pypath(strpath)
fspath = absolutepath(invocation_path / strpath)
fspath = invocation_path / strpath
fspath = absolutepath(fspath)
if not fspath.exists():
msg = (
"module or package not found: {arg} (missing __init__.py?)"

View File

@ -180,6 +180,10 @@ class TestResolveCollectionArgument:
invocation_path / "src/pkg",
[],
)
assert resolve_collection_argument(invocation_path, "src/pkg/test.py::") == (
invocation_path / "src/pkg/test.py",
[],
)
with pytest.raises(
UsageError, match=r"package argument cannot contain :: selection parts"
@ -207,6 +211,12 @@ class TestResolveCollectionArgument:
):
resolve_collection_argument(invocation_path, "src/pkg/test.py[a::b]")
with pytest.raises(
UsageError,
match=re.escape("file or directory not found: src/pkg/test.py[foobar]"),
):
resolve_collection_argument(invocation_path, "src/pkg/test.py[foobar]")
with pytest.raises(
UsageError,
match=re.escape(