Dotted name and parts.
(self, namespace_package: bool, invocation_path: Path)
| 190 | |
| 191 | @pytest.mark.parametrize("namespace_package", [False, True]) |
| 192 | def test_pypath(self, namespace_package: bool, invocation_path: Path) -> None: |
| 193 | """Dotted name and parts.""" |
| 194 | if namespace_package: |
| 195 | # Namespace package doesn't have to contain __init__py |
| 196 | (invocation_path / "src/pkg/__init__.py").unlink() |
| 197 | |
| 198 | assert resolve_collection_argument( |
| 199 | invocation_path, "pkg.test", 0, as_pypath=True |
| 200 | ) == CollectionArgument( |
| 201 | path=invocation_path / "src/pkg/test.py", |
| 202 | parts=[], |
| 203 | parametrization=None, |
| 204 | module_name="pkg.test", |
| 205 | original_index=0, |
| 206 | ) |
| 207 | assert resolve_collection_argument( |
| 208 | invocation_path, "pkg.test::foo::bar", 0, as_pypath=True |
| 209 | ) == CollectionArgument( |
| 210 | path=invocation_path / "src/pkg/test.py", |
| 211 | parts=["foo", "bar"], |
| 212 | parametrization=None, |
| 213 | module_name="pkg.test", |
| 214 | original_index=0, |
| 215 | ) |
| 216 | assert resolve_collection_argument( |
| 217 | invocation_path, |
| 218 | "pkg", |
| 219 | 0, |
| 220 | as_pypath=True, |
| 221 | consider_namespace_packages=namespace_package, |
| 222 | ) == CollectionArgument( |
| 223 | path=invocation_path / "src/pkg", |
| 224 | parts=[], |
| 225 | parametrization=None, |
| 226 | module_name="pkg", |
| 227 | original_index=0, |
| 228 | ) |
| 229 | |
| 230 | with pytest.raises( |
| 231 | UsageError, match=r"package argument cannot contain :: selection parts" |
| 232 | ): |
| 233 | resolve_collection_argument( |
| 234 | invocation_path, |
| 235 | "pkg::foo::bar", |
| 236 | 0, |
| 237 | as_pypath=True, |
| 238 | consider_namespace_packages=namespace_package, |
| 239 | ) |
| 240 | |
| 241 | def test_parametrized_name_with_colons(self, invocation_path: Path) -> None: |
| 242 | assert resolve_collection_argument( |
nothing calls this directly
no test coverage detected