From 4661c8972c4a710aec51edab10994db9f16a973a Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Mon, 1 Mar 2021 13:05:34 +0700 Subject: [PATCH 1/2] Fix failing tests --- tests/test_cli_compile.py | 40 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/tests/test_cli_compile.py b/tests/test_cli_compile.py index a3ef1e582..1842f1b47 100644 --- a/tests/test_cli_compile.py +++ b/tests/test_cli_compile.py @@ -39,17 +39,8 @@ def test_command_line_overrides_pip_conf(pip_with_index_conf, runner): assert "Using indexes:\n http://override.com" in out.stderr -def test_command_line_setuptools_read(make_pip_conf, runner): - make_pip_conf( - dedent( - f"""\ - [global] - disable-pip-version-check = True - find-links = {MINIMAL_WHEELS_PATH} - """ - ) - ) - +@pytest.mark.network +def test_command_line_setuptools_read(runner): with open("setup.py", "w") as package: package.write( dedent( @@ -62,16 +53,13 @@ def test_command_line_setuptools_read(make_pip_conf, runner): """ ) ) - out = runner.invoke(cli, ["--no-emit-find-links"]) + out = runner.invoke( + cli, + ["--no-header", "--no-emit-find-links", "--find-links", MINIMAL_WHEELS_PATH], + ) assert out.stderr == dedent( """\ - # - # This file is autogenerated by pip-compile - # To update, run: - # - # pip-compile --no-emit-find-links - # small-fake-a==0.1 # via fake-setuptools-a (setup.py) """ @@ -81,6 +69,7 @@ def test_command_line_setuptools_read(make_pip_conf, runner): assert os.path.exists("requirements.txt") +@pytest.mark.network @pytest.mark.parametrize( ("options", "expected_output_file"), ( @@ -96,20 +85,10 @@ def test_command_line_setuptools_read(make_pip_conf, runner): (["setup.py", "--output-file", "output.txt"], "output.txt"), ), ) -def test_command_line_setuptools_output_file( - make_pip_conf, runner, options, expected_output_file -): +def test_command_line_setuptools_output_file(runner, options, expected_output_file): """ Test the output files for setup.py as a requirement file. """ - make_pip_conf( - dedent( - f"""\ - [global] - find-links = {MINIMAL_WHEELS_PATH} - """ - ) - ) with open("setup.py", "w") as package: package.write( @@ -126,7 +105,8 @@ def test_command_line_setuptools_output_file( assert os.path.exists(expected_output_file) -def test_command_line_setuptools_nested_output_file(pip_conf, tmpdir, runner): +@pytest.mark.network +def test_command_line_setuptools_nested_output_file(tmpdir, runner): """ Test the output file for setup.py in nested folder as a requirement file. """ From cb704e1d82a9239f01cd280a49b394b7cbe552b1 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Mon, 1 Mar 2021 13:38:32 +0700 Subject: [PATCH 2/2] Add a test that pip-compile setup.py preserves env-markers --- tests/test_cli_compile.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_cli_compile.py b/tests/test_cli_compile.py index 1842f1b47..37d37a64e 100644 --- a/tests/test_cli_compile.py +++ b/tests/test_cli_compile.py @@ -127,6 +127,34 @@ def test_command_line_setuptools_nested_output_file(tmpdir, runner): assert (proj_dir / "requirements.txt").exists() +@pytest.mark.network +def test_setuptools_preserves_environment_markers( + runner, make_package, make_wheel, tmpdir +): + dists_dir = tmpdir / "dists" + + foo_dir = make_package(name="foo", version="1.0") + make_wheel(foo_dir, dists_dir) + + bar_dir = make_package( + name="bar", version="2.0", install_requires=['foo ; python_version >= "1"'] + ) + out = runner.invoke( + cli, + [ + str(bar_dir / "setup.py"), + "--no-header", + "--no-annotate", + "--no-emit-find-links", + "--find-links", + str(dists_dir), + ], + ) + + assert out.exit_code == 0, out.stderr + assert out.stderr == 'foo==1.0 ; python_version >= "1"\n' + + def test_find_links_option(runner): with open("requirements.in", "w") as req_in: req_in.write("-f ./libs3")