Get packages for pipenv check from the target venv.

This commit is contained in:
Yeison Vargas
2022-11-24 00:48:31 -05:00
parent 66153e2436
commit fb9e4d769d
2 changed files with 12 additions and 1 deletions
+12
View File
@@ -2959,6 +2959,16 @@ def do_check(
if safety_project:
options.append(f"--project={safety_project}")
target_venv_packages = run_command(
_cmd + ["-m", "pip", "list", "--format=freeze"], is_verbose=project.s.is_verbose()
)
temp_requirements = tempfile.NamedTemporaryFile(prefix=f"{project.virtualenv_name}_")
temp_requirements.write(target_venv_packages.stdout.strip().encode("utf-8"))
temp_requirements.seek(0)
options.extend(["--file", temp_requirements.name])
cmd = _cmd + [safety_path, "check"] + options
if db:
@@ -3044,6 +3054,8 @@ def do_check(
cli(prog_name="pipenv")
temp_requirements.close()
def do_graph(project, bare=False, json=False, json_tree=False, reverse=False):
import json as jsonlib
-1
View File
@@ -140,7 +140,6 @@ def test_pipenv_graph_reverse(pipenv_instance_private_pypi):
@pytest.mark.cli
@pytest.mark.needs_internet(reason='required by check')
@pytest.mark.skip("Safety 2 ends up scanning the project virtualenv and not the instance created by this test.")
def test_pipenv_check(pipenv_instance_private_pypi):
with pipenv_instance_private_pypi() as p:
c = p.pipenv('install pyyaml')