Skip to content

Commit

Permalink
Fix any_two_not_three test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophia Castellarin committed Jan 8, 2020
1 parent ca1ac1f commit 88fd619
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions conda/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,13 @@ def breadth_first_search_for_dep_graph(self, root_spec, target_name, dep_graph,
continue
visited.append(node)
if node.name == target_name:
target_paths.append(path)
if len(target_paths) == 0:
target_paths.append(path)
if len(target_paths[-1]) == len(path):
last_spec = MatchSpec.union((path[-1], target_paths[-1][-1]))[0]
target_paths[-1][-1] = last_spec
else:
target_paths.append(path)
if len(queue) == 0 or (len(target_paths) == num_targets and any(len(_) != len(path) for _ in queue)):
return target_paths
sub_graph = dep_graph
Expand Down Expand Up @@ -477,14 +480,16 @@ def build_conflict_map(self, specs, specs_to_add=None, history_specs=None):
chains.extend(c)
else:
for node in nodes:
chain = self.breadth_first_search_for_dep_graph(lroots[0], node, dep_graph)
num_occurances = dep_list[node].count(lroots[0])
chain = self.breadth_first_search_for_dep_graph(lroots[0], node, dep_graph, num_occurances)
chains.extend(chain)
if len(current_shortest_chain) == 0 or \
len(chain) < len(current_shortest_chain):
current_shortest_chain = chain
shortest_node = node
for root in lroots[1:]:
c = self.breadth_first_search_for_dep_graph(root, shortest_node, dep_graph)
num_occurances = dep_list[shortest_node].count(root)
c = self.breadth_first_search_for_dep_graph(root, shortest_node, dep_graph, num_occurances)
chains.extend(c)

bad_deps = self._classify_bad_deps(chains, specs_to_add, history_specs,
Expand Down
1 change: 1 addition & 0 deletions tests/test_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ def test_unsat_any_two_not_three():
# a, b and c cannot be installed
with pytest.raises(UnsatisfiableError) as excinfo:
r.install(['a', 'b', 'c'])

assert "a -> d[version='>=1,<2|>=2,<3']" in str(excinfo.value)
assert "b -> d[version='>=1,<2|>=3,<4']" in str(excinfo.value)
assert "c -> d[version='>=2,<3|>=3,<4']" in str(excinfo.value)
Expand Down

0 comments on commit 88fd619

Please sign in to comment.