|
11 | 11 | create_basic_wheel_for_package,
|
12 | 12 | create_test_package_with_setup,
|
13 | 13 | )
|
| 14 | +from tests.lib.wheel import make_wheel |
14 | 15 |
|
15 | 16 |
|
16 | 17 | def assert_installed(script, **kwargs):
|
@@ -1089,3 +1090,45 @@ def test_new_resolver_presents_messages_when_backtracking_a_lot(script, N):
|
1089 | 1090 | assert result.stdout.count("This could take a while.") >= 2
|
1090 | 1091 | if N >= 13:
|
1091 | 1092 | assert "press Ctrl + C" in result.stdout
|
| 1093 | + |
| 1094 | + |
| 1095 | +@pytest.mark.parametrize( |
| 1096 | + "metadata_version", |
| 1097 | + [ |
| 1098 | + "0.1.0+local.1", # Normalized form. |
| 1099 | + "0.1.0+local_1", # Non-normalized form containing an underscore. |
| 1100 | +
|
| 1101 | + # Non-normalized form containing a dash. This is allowed, installation |
| 1102 | + # works correctly, but assert_installed() fails because pkg_resources |
| 1103 | + # cannot handle it correctly. Nobody is complaining about it right now, |
| 1104 | + # we're probably dropping it for importlib.metadata soon(tm), so let's |
| 1105 | + # ignore it for the time being. |
| 1106 | + pytest.param("0.1.0+local-1", marks=pytest.mark.xfail), |
| 1107 | + ], |
| 1108 | + ids=["meta_dot", "meta_underscore", "meta_dash"], |
| 1109 | +) |
| 1110 | +@pytest.mark.parametrize( |
| 1111 | + "filename_version", |
| 1112 | + [ |
| 1113 | + ("0.1.0+local.1"), # Tools are encouraged to use this. |
| 1114 | + ("0.1.0+local_1"), # But this is allowed (version not normalized). |
| 1115 | + ], |
| 1116 | + ids=["file_dot", "file_underscore"], |
| 1117 | +) |
| 1118 | +def test_new_resolver_check_wheel_version_normalized( |
| 1119 | + script, |
| 1120 | + metadata_version, |
| 1121 | + filename_version, |
| 1122 | +): |
| 1123 | + filename = "simple-{}-py2.py3-none-any.whl".format(filename_version) |
| 1124 | + |
| 1125 | + wheel_builder = make_wheel(name="simple", version=metadata_version) |
| 1126 | + wheel_builder.save_to(script.scratch_path / filename) |
| 1127 | + |
| 1128 | + script.pip( |
| 1129 | + "install", |
| 1130 | + "--no-cache-dir", "--no-index", |
| 1131 | + "--find-links", script.scratch_path, |
| 1132 | + "simple" |
| 1133 | + ) |
| 1134 | + assert_installed(script, simple="0.1.0+local.1") |
0 commit comments