Skip to content

Commit

Permalink
add separate test for editable packages
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Apr 30, 2024
1 parent ae03436 commit ec80028
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions tests/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,47 @@ def test_exporter_can_export_requirements_txt_with_directory_packages(
assert content == expected


def test_exporter_can_export_requirements_txt_with_directory_packages_editable(
tmp_path: Path, poetry: Poetry, fixture_root_uri: str
) -> None:
poetry.locker.mock_lock_data( # type: ignore[attr-defined]
{
"package": [
{
"name": "foo",
"version": "1.2.3",
"optional": False,
"python-versions": "*",
"develop": True,
"source": {
"type": "directory",
"url": "sample_project",
"reference": "",
},
}
],
"metadata": {
"python-versions": "*",
"content-hash": "123456789",
"files": {"foo": []},
},
}
)
set_package_requires(poetry)

exporter = Exporter(poetry, NullIO())
exporter.export("requirements.txt", tmp_path, "requirements.txt")

with (tmp_path / "requirements.txt").open(encoding="utf-8") as f:
content = f.read()

expected = f"""\
-e {fixture_root_uri}/sample_project ; {MARKER_PY}
"""

assert content == expected


def test_exporter_can_export_requirements_txt_with_nested_directory_packages(
tmp_path: Path, poetry: Poetry, fixture_root_uri: str
) -> None:
Expand Down Expand Up @@ -1300,8 +1341,7 @@ def test_exporter_can_export_requirements_txt_with_nested_directory_packages(
"version": "7.8.9",
"optional": False,
"python-versions": "*",
"develop": True,
"source": {
"source": {
"type": "directory",
"url": "sample_project/../project_with_nested_local/bar/..",
"reference": "",
Expand All @@ -1324,8 +1364,8 @@ def test_exporter_can_export_requirements_txt_with_nested_directory_packages(
content = f.read()

expected = f"""\
-e {fixture_root_uri}/project_with_nested_local ; {MARKER_PY}
bar @ {fixture_root_uri}/project_with_nested_local/bar ; {MARKER_PY}
baz @ {fixture_root_uri}/project_with_nested_local ; {MARKER_PY}
foo @ {fixture_root_uri}/sample_project ; {MARKER_PY}
"""

Expand Down

0 comments on commit ec80028

Please sign in to comment.