|
7 | 7 | import pytest
|
8 | 8 | from pip._vendor.packaging.utils import canonicalize_name
|
9 | 9 |
|
| 10 | +from pip._internal.models.direct_url import DirectUrl |
10 | 11 | from tests.lib import (
|
11 | 12 | _create_test_package,
|
12 | 13 | _create_test_package_with_srcdir,
|
|
19 | 20 | path_to_url,
|
20 | 21 | wheel,
|
21 | 22 | )
|
| 23 | +from tests.lib.direct_url import get_created_direct_url_path |
22 | 24 |
|
23 | 25 | distribute_re = re.compile('^distribute==[0-9.]+\n', re.MULTILINE)
|
24 | 26 |
|
@@ -833,3 +835,22 @@ def test_freeze_include_work_dir_pkg(script):
|
833 | 835 | # when package directory is in PYTHONPATH
|
834 | 836 | result = script.pip('freeze', cwd=pkg_path)
|
835 | 837 | assert 'simple==1.0' in result.stdout
|
| 838 | + |
| 839 | + |
| 840 | +def test_freeze_pep610_editable(script, with_wheel): |
| 841 | + """ |
| 842 | + Test that a package installed with a direct_url.json with editable=true |
| 843 | + is correctly frozeon as editable. |
| 844 | + """ |
| 845 | + pkg_path = _create_test_package(script, name="testpkg") |
| 846 | + result = script.pip("install", pkg_path) |
| 847 | + direct_url_path = get_created_direct_url_path(result, "testpkg") |
| 848 | + assert direct_url_path |
| 849 | + # patch direct_url.json to simulate an editable install |
| 850 | + with open(direct_url_path) as f: |
| 851 | + direct_url = DirectUrl.from_json(f.read()) |
| 852 | + direct_url.info.editable = True |
| 853 | + with open(direct_url_path, "w") as f: |
| 854 | + f.write(direct_url.to_json()) |
| 855 | + result = script.pip("freeze") |
| 856 | + assert "# Editable Git install with no remote (testpkg==0.1)" in result.stdout |
0 commit comments