Skip to content

Commit fe98ea4

Browse files
committed
With poetry export fixture
1 parent b958f5f commit fe98ea4

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

test/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import os
23
import subprocess
34
from inspect import cleandoc
45

@@ -22,6 +23,21 @@ def poetry_path() -> str:
2223
return poetry_path
2324

2425

26+
@pytest.fixture
27+
def install_poetry_export(poetry_path, monkeypatch):
28+
monkeypatch.setenv("PATH", poetry_path, prepend=os.pathsep)
29+
30+
def _install(cwd):
31+
subprocess.run(
32+
["poetry", "self", "add", "poetry-plugin-export"],
33+
cwd=cwd,
34+
env=os.environ,
35+
check=True,
36+
)
37+
38+
return _install
39+
40+
2541
class SampleVulnerability:
2642
package_name = "jinja2"
2743
version = "3.1.5"

test/unit/util/dependencies/audit_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,15 @@ def extract_package_names(content) -> list[str]:
164164
"new_pyproject_toml",
165165
],
166166
)
167-
def test_poetry_export_versions(self, tmp_path, pyproject_content, request):
167+
def test_poetry_export_versions(
168+
self, install_poetry_export, tmp_path, pyproject_content, request
169+
):
168170
content_str = request.getfixturevalue(pyproject_content)
169171
(tmp_path / "pyproject.toml").write_text(content_str)
170172
requirements_txt = tmp_path / "requirements.txt"
171173

174+
install_poetry_export(cwd=tmp_path)
175+
172176
export_dependencies_to_file(
173177
output_file=requirements_txt, working_directory=tmp_path
174178
)

0 commit comments

Comments
 (0)