From f0a6ef5bc72edab5a4a6ef82c437846a84f370b2 Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Thu, 2 Feb 2023 10:28:34 -0500 Subject: [PATCH] Integration test for merging requirements without names --- tests/test_cli_sync.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_cli_sync.py b/tests/test_cli_sync.py index bb58b028a..de56f45ef 100644 --- a/tests/test_cli_sync.py +++ b/tests/test_cli_sync.py @@ -3,6 +3,7 @@ import os import subprocess import sys +from pathlib import Path from unittest import mock import pytest @@ -128,6 +129,31 @@ def test_merge_error(req_lines, should_raise, runner): assert out.exit_code == 1 +@pytest.mark.parametrize( + "req_line", + ( + "file:.", + "-e file:.", + ), +) +@mock.patch("piptools.sync.run") +def test_merge_no_name_urls(run, req_line, runner): + """ + Test sync succeeds when merging requirements that lack names. + """ + reqs_paths = [ + Path(name).absolute() for name in ("requirements.txt", "dev_requirements.txt") + ] + + for reqs_path in reqs_paths: + with reqs_path.open("w") as req_out: + req_out.write(f"{req_line} \n") + + out = runner.invoke(cli, [str(path) for path in reqs_paths]) + assert out.exit_code == 0 + assert run.call_count == 2 + + @pytest.mark.parametrize( ("cli_flags", "expected_install_flags"), (