From d3fa982b6595ba8d5fa134ed4e8125cdfbfe5607 Mon Sep 17 00:00:00 2001 From: Andy Kluger Date: Thu, 2 Nov 2023 18:49:37 -0400 Subject: [PATCH] Add test: canonicalize_extras Based on the case in #2004 --- tests/test_cli_compile.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/test_cli_compile.py b/tests/test_cli_compile.py index 52188af4..b4da4280 100644 --- a/tests/test_cli_compile.py +++ b/tests/test_cli_compile.py @@ -2374,6 +2374,45 @@ def test_combine_different_extras_of_the_same_package( ) +def test_canonicalize_extras(pip_conf, runner, tmp_path, make_package, make_wheel): + """ + Ensure extras are written in a consistent format. + """ + pkgs = [ + make_package( + "fake-sqlalchemy", + version="0.1", + extras_require={"fake-postgresql_psycoPG2BINARY": ["fake-greenlet"]}, + ), + make_package( + "fake-greenlet", + version="0.2", + ), + ] + + dists_dir = tmp_path / "dists" + for pkg in pkgs: + make_wheel(pkg, dists_dir) + + with open("requirements.in", "w") as req_in: + req_in.write("fake-sqlalchemy[fake-postgresql_psycoPG2BINARY]\n") + + out = runner.invoke( + cli, + [ + "--output-file", + "-", + "--find-links", + str(dists_dir), + "--no-header", + "--no-emit-options", + "--no-annotate", + ], + ) + assert out.exit_code == 0 + assert out.stdout == "fake-sqlalchemy[fake-postgresql-psycopg2binary]==0.1\n" + + @pytest.mark.parametrize( ("pkg2_install_requires", "req_in_content", "out_expected_content"), (