|
1 | 1 | import os
|
| 2 | +import pathlib |
2 | 3 | import sys
|
3 | 4 | import textwrap
|
4 | 5 |
|
@@ -1962,3 +1963,49 @@ def test_new_resolver_transitively_depends_on_unnamed_local(script):
|
1962 | 1963 | certbot_apache="99.99.0.dev0",
|
1963 | 1964 | certbot_docs="1",
|
1964 | 1965 | )
|
| 1966 | + |
| 1967 | + |
| 1968 | +def _to_uri(path): |
| 1969 | + # Something like file:///path/to/package |
| 1970 | + return pathlib.Path(path).as_uri() |
| 1971 | + |
| 1972 | + |
| 1973 | +def _to_localhost_uri(path): |
| 1974 | + # Something like file://localhost/path/to/package |
| 1975 | + return pathlib.Path(path).as_uri().replace("///", "//localhost/") |
| 1976 | + |
| 1977 | + |
| 1978 | +@pytest.mark.parametrize( |
| 1979 | + "format_dep", |
| 1980 | + [ |
| 1981 | + pytest.param(_to_uri, id="emptyhost"), |
| 1982 | + pytest.param(_to_localhost_uri, id="localhost"), |
| 1983 | + ], |
| 1984 | +) |
| 1985 | +@pytest.mark.parametrize( |
| 1986 | + "format_input", |
| 1987 | + [ |
| 1988 | + pytest.param(lambda path: path, id="path"), |
| 1989 | + pytest.param(_to_uri, id="emptyhost"), |
| 1990 | + pytest.param(_to_localhost_uri, id="localhost"), |
| 1991 | + ], |
| 1992 | +) |
| 1993 | +def test_new_resolver_file_url_normalize(script, format_dep, format_input): |
| 1994 | + lib_a = create_test_package_with_setup( |
| 1995 | + script, |
| 1996 | + name="lib_a", |
| 1997 | + version="1", |
| 1998 | + ) |
| 1999 | + lib_b = create_test_package_with_setup( |
| 2000 | + script, |
| 2001 | + name="lib_b", |
| 2002 | + version="1", |
| 2003 | + install_requires=[f"lib_a @ {format_dep(lib_a)}"], |
| 2004 | + ) |
| 2005 | + |
| 2006 | + script.pip( |
| 2007 | + "install", |
| 2008 | + "--no-cache-dir", "--no-index", |
| 2009 | + format_input(lib_a), lib_b, |
| 2010 | + ) |
| 2011 | + script.assert_installed(lib_a="1", lib_b="1") |
0 commit comments