forked from conda/conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_api.py
60 lines (51 loc) · 1.81 KB
/
test_api.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import inspect
from conda.api import Solver
from conda.common.compat import odict
from conda.common.constants import NULL
def inspect_arguments(f, arguments):
result = inspect.getargspec(f)
arg_names = result[0]
default_val_first_idx = len(arg_names) - len(result.defaults)
arg_values = [NULL] * default_val_first_idx + list(result.defaults)
for (recorded_name, recorded_value), (arg_name, arg_value) in zip(arguments.items(), zip(arg_names, arg_values)):
print(recorded_name, arg_name)
assert recorded_name == arg_name
assert recorded_value == arg_value
def test_Solver_contract():
init_args = odict((
('self', NULL),
('prefix', NULL),
('channels', NULL),
('subdirs', ()),
('specs_to_add', ()),
('specs_to_remove', ()),
))
inspect_arguments(Solver.__init__, init_args)
solve_final_state_args = odict((
('self', NULL),
('deps_modifier', NULL),
('prune', NULL),
('ignore_pinned', NULL),
('force_remove', NULL),
))
inspect_arguments(Solver.solve_final_state, solve_final_state_args)
solve_for_diff_args = odict((
('self', NULL),
('deps_modifier', NULL),
('prune', NULL),
('ignore_pinned', NULL),
('force_remove', NULL),
('force_reinstall', False),
))
inspect_arguments(Solver.solve_for_diff, solve_for_diff_args)
solve_for_transaction_args = odict((
('self', NULL),
('deps_modifier', NULL),
('prune', NULL),
('ignore_pinned', NULL),
('force_remove', NULL),
('force_reinstall', False),
))
inspect_arguments(Solver.solve_for_transaction, solve_for_transaction_args)