Merge pull request #9649 from pytest-dev/backport-9642-to-7.0.x
This commit is contained in:
		
						commit
						a24c78b7af
					
				| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					Fix running tests by id with ``::`` in the parametrize portion.
 | 
				
			||||||
| 
						 | 
					@ -871,7 +871,10 @@ def resolve_collection_argument(
 | 
				
			||||||
    If the path doesn't exist, raise UsageError.
 | 
					    If the path doesn't exist, raise UsageError.
 | 
				
			||||||
    If the path is a directory and selection parts are present, raise UsageError.
 | 
					    If the path is a directory and selection parts are present, raise UsageError.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    strpath, *parts = str(arg).split("::")
 | 
					    base, squacket, rest = str(arg).partition("[")
 | 
				
			||||||
 | 
					    strpath, *parts = base.split("::")
 | 
				
			||||||
 | 
					    if parts:
 | 
				
			||||||
 | 
					        parts[-1] = f"{parts[-1]}{squacket}{rest}"
 | 
				
			||||||
    if as_pypath:
 | 
					    if as_pypath:
 | 
				
			||||||
        strpath = search_pypath(strpath)
 | 
					        strpath = search_pypath(strpath)
 | 
				
			||||||
    fspath = invocation_path / strpath
 | 
					    fspath = invocation_path / strpath
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -171,6 +171,12 @@ class TestResolveCollectionArgument:
 | 
				
			||||||
                invocation_path, "pkg::foo::bar", as_pypath=True
 | 
					                invocation_path, "pkg::foo::bar", as_pypath=True
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_parametrized_name_with_colons(self, invocation_path: Path) -> None:
 | 
				
			||||||
 | 
					        ret = resolve_collection_argument(
 | 
				
			||||||
 | 
					            invocation_path, "src/pkg/test.py::test[a::b]"
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        assert ret == (invocation_path / "src/pkg/test.py", ["test[a::b]"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_does_not_exist(self, invocation_path: Path) -> None:
 | 
					    def test_does_not_exist(self, invocation_path: Path) -> None:
 | 
				
			||||||
        """Given a file/module that does not exist raises UsageError."""
 | 
					        """Given a file/module that does not exist raises UsageError."""
 | 
				
			||||||
        with pytest.raises(
 | 
					        with pytest.raises(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue