|
8 | 8 |
|
9 | 9 | def pip(script, command, requirement):
|
10 | 10 | return script.pip(
|
11 |
| - command, '--prefer-binary', '--no-cache-dir', |
12 |
| - '--use-feature=fast-deps', requirement, |
| 11 | + command, |
| 12 | + "--prefer-binary", |
| 13 | + "--no-cache-dir", |
| 14 | + "--use-feature=fast-deps", |
| 15 | + requirement, |
13 | 16 | allow_stderr_warning=True,
|
14 | 17 | )
|
15 | 18 |
|
16 | 19 |
|
17 | 20 | def assert_installed(script, names):
|
18 |
| - list_output = json.loads(script.pip('list', '--format=json').stdout) |
19 |
| - installed = {canonicalize_name(item['name']) for item in list_output} |
| 21 | + list_output = json.loads(script.pip("list", "--format=json").stdout) |
| 22 | + installed = {canonicalize_name(item["name"]) for item in list_output} |
20 | 23 | assert installed.issuperset(map(canonicalize_name, names))
|
21 | 24 |
|
22 | 25 |
|
23 | 26 | @mark.network
|
24 |
| -@mark.parametrize(('requirement', 'expected'), ( |
25 |
| - ('Paste==3.4.2', ('Paste', 'six')), |
26 |
| - ('Paste[flup]==3.4.2', ('Paste', 'six', 'flup')), |
27 |
| -)) |
| 27 | +@mark.parametrize( |
| 28 | + ("requirement", "expected"), |
| 29 | + ( |
| 30 | + ("Paste==3.4.2", ("Paste", "six")), |
| 31 | + ("Paste[flup]==3.4.2", ("Paste", "six", "flup")), |
| 32 | + ), |
| 33 | +) |
28 | 34 | def test_install_from_pypi(requirement, expected, script):
|
29 |
| - pip(script, 'install', requirement) |
| 35 | + pip(script, "install", requirement) |
30 | 36 | assert_installed(script, expected)
|
31 | 37 |
|
32 | 38 |
|
33 | 39 | @mark.network
|
34 |
| -@mark.parametrize(('requirement', 'expected'), ( |
35 |
| - ('Paste==3.4.2', ('Paste-3.4.2-*.whl', 'six-*.whl')), |
36 |
| - ('Paste[flup]==3.4.2', ('Paste-3.4.2-*.whl', 'six-*.whl', 'flup-*')), |
37 |
| -)) |
| 40 | +@mark.parametrize( |
| 41 | + ("requirement", "expected"), |
| 42 | + ( |
| 43 | + ("Paste==3.4.2", ("Paste-3.4.2-*.whl", "six-*.whl")), |
| 44 | + ("Paste[flup]==3.4.2", ("Paste-3.4.2-*.whl", "six-*.whl", "flup-*")), |
| 45 | + ), |
| 46 | +) |
38 | 47 | def test_download_from_pypi(requirement, expected, script):
|
39 |
| - result = pip(script, 'download', requirement) |
| 48 | + result = pip(script, "download", requirement) |
40 | 49 | created = list(map(basename, result.files_created))
|
41 | 50 | assert all(fnmatch.filter(created, f) for f in expected)
|
42 | 51 |
|
43 | 52 |
|
44 | 53 | @mark.network
|
45 | 54 | def test_build_wheel_with_deps(data, script):
|
46 |
| - result = pip(script, 'wheel', data.packages/'requiresPaste') |
| 55 | + result = pip(script, "wheel", data.packages / "requiresPaste") |
47 | 56 | created = list(map(basename, result.files_created))
|
48 |
| - assert fnmatch.filter(created, 'requiresPaste-3.1.4-*.whl') |
49 |
| - assert fnmatch.filter(created, 'Paste-3.4.2-*.whl') |
50 |
| - assert fnmatch.filter(created, 'six-*.whl') |
| 57 | + assert fnmatch.filter(created, "requiresPaste-3.1.4-*.whl") |
| 58 | + assert fnmatch.filter(created, "Paste-3.4.2-*.whl") |
| 59 | + assert fnmatch.filter(created, "six-*.whl") |
51 | 60 |
|
52 | 61 |
|
53 | 62 | @mark.network
|
54 | 63 | def test_require_hash(script, tmp_path):
|
55 |
| - reqs = tmp_path / 'requirements.txt' |
| 64 | + reqs = tmp_path / "requirements.txt" |
56 | 65 | reqs.write_text(
|
57 |
| - 'idna==2.10' |
58 |
| - ' --hash=sha256:' |
59 |
| - 'b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0' |
60 |
| - ' --hash=sha256:' |
61 |
| - 'b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6' |
| 66 | + "idna==2.10" |
| 67 | + " --hash=sha256:" |
| 68 | + "b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" |
| 69 | + " --hash=sha256:" |
| 70 | + "b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6" |
62 | 71 | )
|
63 | 72 | result = script.pip(
|
64 |
| - 'download', '--use-feature=fast-deps', '-r', str(reqs), |
| 73 | + "download", |
| 74 | + "--use-feature=fast-deps", |
| 75 | + "-r", |
| 76 | + str(reqs), |
65 | 77 | allow_stderr_warning=True,
|
66 | 78 | )
|
67 | 79 | created = list(map(basename, result.files_created))
|
68 |
| - assert fnmatch.filter(created, 'idna-2.10*') |
| 80 | + assert fnmatch.filter(created, "idna-2.10*") |
69 | 81 |
|
70 | 82 |
|
71 | 83 | @mark.network
|
72 | 84 | def test_hash_mismatch(script, tmp_path):
|
73 |
| - reqs = tmp_path / 'requirements.txt' |
74 |
| - reqs.write_text('idna==2.10 --hash=sha256:irna') |
| 85 | + reqs = tmp_path / "requirements.txt" |
| 86 | + reqs.write_text("idna==2.10 --hash=sha256:irna") |
75 | 87 | result = script.pip(
|
76 |
| - 'download', '--use-feature=fast-deps', '-r', str(reqs), |
| 88 | + "download", |
| 89 | + "--use-feature=fast-deps", |
| 90 | + "-r", |
| 91 | + str(reqs), |
77 | 92 | expect_error=True,
|
78 | 93 | )
|
79 |
| - assert 'DO NOT MATCH THE HASHES' in result.stderr |
| 94 | + assert "DO NOT MATCH THE HASHES" in result.stderr |
0 commit comments