Skip to content

Commit 3f005f2

Browse files
committed
Add integration tests for experimental feature fast-deps
Test pip {download,install,wheel} where requirements have dependencies listed in their wheels' metadata.
1 parent 7492941 commit 3f005f2

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[build-system]
2+
requires = ['flit_core >=2,<4']
3+
build-backend = 'flit_core.buildapi'
4+
5+
[tool.flit.metadata]
6+
module = 'requiresPaste'
7+
author = 'A. Random Developer'
8+
author-email = '[email protected]'
9+
requires = ['Paste==3.4.2']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Module requiring Paste to test dependencies download of pip wheel."""
2+
3+
__version__ = '3.1.4'

tests/functional/test_fast_deps.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import fnmatch
2+
import json
3+
from os.path import basename
4+
5+
from pip._vendor.packaging.utils import canonicalize_name
6+
from pytest import mark
7+
8+
9+
def pip(script, command, requirement):
10+
return script.pip(
11+
command, '--prefer-binary', '--no-cache-dir',
12+
'--use-feature=fast-deps', requirement,
13+
allow_stderr_warning=True,
14+
)
15+
16+
17+
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}
20+
assert installed.issuperset(map(canonicalize_name, names))
21+
22+
23+
@mark.network
24+
@mark.parametrize(('requirement', 'expected'), (
25+
('Paste==3.4.2', ('Paste', 'six')),
26+
('Paste[flup]==3.4.2', ('Paste', 'six', 'flup')),
27+
))
28+
def test_install_from_pypi(requirement, expected, script):
29+
pip(script, 'install', requirement)
30+
assert_installed(script, expected)
31+
32+
33+
@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+
))
38+
def test_download_from_pypi(requirement, expected, script):
39+
result = pip(script, 'download', requirement)
40+
created = list(map(basename, result.files_created))
41+
assert all(fnmatch.filter(created, f) for f in expected)
42+
43+
44+
@mark.network
45+
def test_build_wheel_with_deps(data, script):
46+
result = pip(script, 'wheel', data.packages/'requiresPaste')
47+
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')

0 commit comments

Comments
 (0)