diff --git a/openstack_requirements/cmds/build_lower_constraints.py b/openstack_requirements/cmds/build_lower_constraints.py index b79eaa1762..438270f5d7 100644 --- a/openstack_requirements/cmds/build_lower_constraints.py +++ b/openstack_requirements/cmds/build_lower_constraints.py @@ -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() diff --git a/openstack_requirements/tests/test_build_lower_constraints.py b/openstack_requirements/tests/test_build_lower_constraints.py index 75b2f3ac71..5f820f4885 100644 --- a/openstack_requirements/tests/test_build_lower_constraints.py +++ b/openstack_requirements/tests/test_build_lower_constraints.py @@ -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)) + )