-
Notifications
You must be signed in to change notification settings - Fork 54
/
test_minimal_upgrade.py
46 lines (43 loc) · 1.58 KB
/
test_minimal_upgrade.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pytest
from piptools.repositories import LocalRequirementsRepository
from piptools.utils import name_from_req
@pytest.mark.parametrize(
("input", "pins", "expected"),
(
(tup)
for tup in [
# Add Flask to an existing requirements.in, using --no-upgrade
(
["flask", "jinja2", "werkzeug"],
[
# The requirements.txt from a previous round
"jinja2==2.7.3",
"markupsafe==0.23",
"werkzeug==0.6",
],
[
# Add flask and upgrade werkzeug from incompatible 0.6
"flask==0.10.1",
"itsdangerous==0.24 (from flask==0.10.1)",
"werkzeug==0.10.4",
# Other requirements are unchanged from
# the original requirements.txt
"jinja2==2.7.3",
"markupsafe==0.23 (from jinja2==2.7.3)",
],
)
]
),
)
def test_no_upgrades(base_resolver, repository, from_line, input, pins, expected):
input = [from_line(line) for line in input]
existing_pins = dict()
for line in pins:
ireq = from_line(line)
existing_pins[name_from_req(ireq.req)] = ireq
local_repository = LocalRequirementsRepository(existing_pins, repository)
output = base_resolver(
input, prereleases=False, repository=local_repository
).resolve()
output = {str(line) for line in output}
assert output == {str(line) for line in expected}