Skip to content

Commit 06c42b2

Browse files
authored
Fix: Include explicit sources in export command (#205)
1 parent 208a5e3 commit 06c42b2

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

src/poetry_plugin_export/exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _export_generic_txt(
173173
for index in sorted(indexes):
174174
repositories = [
175175
r
176-
for r in self._poetry.pool.repositories
176+
for r in self._poetry.pool.all_repositories
177177
if isinstance(r, HTTPRepository) and r.url == index.rstrip("/")
178178
]
179179
if not repositories:

tests/test_exporter.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,3 +2663,60 @@ def test_exporter_tolerates_non_existent_extra(tmp_path: Path, poetry: Poetry) -
26632663
foo[baz]==1.2.3 ; {MARKER_PY27} or {MARKER_PY36}
26642664
"""
26652665
assert content == expected
2666+
2667+
2668+
def test_exporter_exports_extra_index_url_and_trusted_host(
2669+
tmp_path: Path, poetry: Poetry
2670+
) -> None:
2671+
poetry.pool.add_repository(
2672+
LegacyRepository(
2673+
"custom",
2674+
"http://example.com/simple",
2675+
),
2676+
priority=Priority.EXPLICIT,
2677+
)
2678+
poetry.locker.mock_lock_data( # type: ignore[attr-defined]
2679+
{
2680+
"package": [
2681+
{
2682+
"name": "foo",
2683+
"version": "1.2.3",
2684+
"optional": False,
2685+
"python-versions": "*",
2686+
"dependencies": {"bar": "*"},
2687+
},
2688+
{
2689+
"name": "bar",
2690+
"version": "4.5.6",
2691+
"optional": False,
2692+
"python-versions": "*",
2693+
"source": {
2694+
"type": "legacy",
2695+
"url": "http://example.com/simple",
2696+
"reference": "",
2697+
},
2698+
},
2699+
],
2700+
"metadata": {
2701+
"python-versions": "*",
2702+
"content-hash": "123456789",
2703+
"files": {"foo": [], "bar": []},
2704+
},
2705+
}
2706+
)
2707+
set_package_requires(poetry)
2708+
2709+
exporter = Exporter(poetry, NullIO())
2710+
exporter.export("requirements.txt", tmp_path, "requirements.txt")
2711+
2712+
with (tmp_path / "requirements.txt").open(encoding="utf-8") as f:
2713+
content = f.read()
2714+
2715+
expected = f"""\
2716+
--trusted-host example.com
2717+
--extra-index-url http://example.com/simple
2718+
2719+
bar==4.5.6 ; {MARKER_PY}
2720+
foo==1.2.3 ; {MARKER_PY}
2721+
"""
2722+
assert content == expected

0 commit comments

Comments
 (0)