Merge "Ignore empty requirements/constraints when building lower-constraints"

This commit is contained in:
Zuul 2018-07-05 11:59:45 +00:00 committed by Gerrit Code Review
commit 427c73372e
2 changed files with 14 additions and 1 deletions

View File

@ -48,7 +48,8 @@ def merge_constraints_sets(constraints_sets):
all_constraints = collections.defaultdict(list)
for constraints_set in constraints_sets:
for constraint_name, constraint in constraints_set.items():
all_constraints[constraint_name].extend(constraint)
if constraint_name:
all_constraints[constraint_name].extend(constraint)
for constraint_name, constraints in sorted(all_constraints.items()):
val = max((c[0] for c in constraints), key=get_requirements_version)
yield val.to_line()

View File

@ -55,3 +55,15 @@ class BuildLowerConstraintsTest(testtools.TestCase):
expected,
list(build_lower_constraints.merge_constraints_sets(inputs))
)
def test_one_input_file_with_comments(self):
inputs = [
requirement.parse('package==1.2.3\n # package2==0.9.8'),
]
expected = [
'package==1.2.3\n',
]
self.assertEqual(
expected,
list(build_lower_constraints.merge_constraints_sets(inputs))
)