diff --git a/openstack_requirements/cmds/update.py b/openstack_requirements/cmds/update.py index 10bba91c87..503e78edad 100644 --- a/openstack_requirements/cmds/update.py +++ b/openstack_requirements/cmds/update.py @@ -111,7 +111,7 @@ def _sync_requirements_file( elif req is None: # Unparsable lines. output_requirements.append( - requirement.Requirement('', '', '', '', req_line)) + requirement.Requirement('', '', '', '', req_line.rstrip())) continue elif not req.package: # Comment-only lines diff --git a/openstack_requirements/tests/test_update.py b/openstack_requirements/tests/test_update.py index 1d02b1e718..67b965d863 100644 --- a/openstack_requirements/tests/test_update.py +++ b/openstack_requirements/tests/test_update.py @@ -366,6 +366,24 @@ class TestSyncRequirementsFile(testtools.TestCase): " foo>1;python_version!='2.7' -> \n"), actions[3]) self.assertThat(actions, matchers.HasLength(4)) + def test_unparseable_line(self): + global_content = textwrap.dedent("""\ + foo + """) + project_content = textwrap.dedent("""\ + foo + -e git://git.openstack.org/openstack/neutron.git#egg=neutron + """) + global_reqs = requirement.parse(global_content) + project_reqs = list(requirement.to_reqs(project_content)) + actions, reqs = update._sync_requirements_file( + global_reqs, project_reqs, 'f', False, False, False) + n = '-e git://git.openstack.org/openstack/neutron.git#egg=neutron' + self.assertEqual(requirement.Requirements([ + requirement.Requirement('foo', '', '', '', ''), + requirement.Requirement('', '', '', '', n)]), + reqs) + class TestCopyRequires(testtools.TestCase):