From def0dd5bfb4dcc634173da2653cbde1a27ec4200 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Thu, 29 Jun 2023 16:38:10 +0200 Subject: [PATCH 1/2] Downgrade log level for configuration defaults message --- piptools/scripts/compile.py | 2 +- piptools/scripts/sync.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/piptools/scripts/compile.py b/piptools/scripts/compile.py index 837bb0f23..35476ec4b 100755 --- a/piptools/scripts/compile.py +++ b/piptools/scripts/compile.py @@ -410,7 +410,7 @@ def cli( ) if config: - log.info(f"Using pip-tools configuration defaults found in '{config !s}'.") + log.debug(f"Using pip-tools configuration defaults found in '{config !s}'.") if resolver_name == "legacy": log.warning( diff --git a/piptools/scripts/sync.py b/piptools/scripts/sync.py index d504d889a..63e4eb816 100755 --- a/piptools/scripts/sync.py +++ b/piptools/scripts/sync.py @@ -147,7 +147,7 @@ def cli( sys.exit(2) if config: - log.info(f"Using pip-tools configuration defaults found in '{config !s}'.") + log.debug(f"Using pip-tools configuration defaults found in '{config !s}'.") if python_executable: _validate_python_executable(python_executable) From e6256950a3f5408216cf3e25b25660e695d65e72 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Thu, 29 Jun 2023 19:37:47 +0200 Subject: [PATCH 2/2] Fix decreased coverage --- tests/test_cli_compile.py | 12 ++++++++++++ tests/test_cli_sync.py | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tests/test_cli_compile.py b/tests/test_cli_compile.py index 2650af2f6..df677d8d6 100644 --- a/tests/test_cli_compile.py +++ b/tests/test_cli_compile.py @@ -2925,3 +2925,15 @@ def test_compile_recursive_extras(runner, tmp_path, current_resolver): """ assert out.exit_code == 0 assert expected == out.stderr + + +def test_config_option(pip_conf, runner, tmp_path, make_config_file): + config_file = make_config_file("dry-run", True) + + req_in = tmp_path / "requirements.in" + req_in.touch() + + out = runner.invoke(cli, [req_in.as_posix(), "--config", config_file.as_posix()]) + + assert out.exit_code == 0 + assert "Dry-run, so nothing updated" in out.stderr diff --git a/tests/test_cli_sync.py b/tests/test_cli_sync.py index 78f5637d1..e7ec3c43f 100644 --- a/tests/test_cli_sync.py +++ b/tests/test_cli_sync.py @@ -372,3 +372,16 @@ def test_default_python_executable_option(run, runner): "-r", ] ] + + +@mock.patch("piptools.sync.run") +def test_config_option(run, runner, make_config_file): + config_file = make_config_file("dry-run", True) + + with open(sync.DEFAULT_REQUIREMENTS_FILE, "w") as reqs_txt: + reqs_txt.write("six==1.10.0") + + out = runner.invoke(cli, ["--config", config_file.as_posix()]) + + assert out.exit_code == 1 + assert "Would install:" in out.stdout