diff --git a/openstack_requirements/cmds/edit_constraint.py b/openstack_requirements/cmds/edit_constraint.py index ebc98abe16..3a2ece224c 100644 --- a/openstack_requirements/cmds/edit_constraint.py +++ b/openstack_requirements/cmds/edit_constraint.py @@ -24,7 +24,8 @@ def edit(reqs, name, replacement): if not replacement: reqs.pop(name, None) else: - reqs[name] = [(requirement.Requirement('', '', '', replacement), '')] + reqs[name] = [ + (requirement.Requirement('', '', '', '', replacement), '')] result = [] for entries in reqs.values(): for entry, _ in entries: diff --git a/openstack_requirements/cmds/update.py b/openstack_requirements/cmds/update.py index fb51b740c5..10bba91c87 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)) continue elif not req.package: # Comment-only lines diff --git a/openstack_requirements/requirement.py b/openstack_requirements/requirement.py index 4fd7a1f314..b396e1bf44 100644 --- a/openstack_requirements/requirement.py +++ b/openstack_requirements/requirement.py @@ -31,7 +31,7 @@ _REQS_HEADER = [ Requirement = collections.namedtuple( - 'Requirement', ['package', 'specifiers', 'markers', 'comment']) + 'Requirement', ['package', 'location', 'specifiers', 'markers', 'comment']) Requirements = collections.namedtuple('Requirements', ['reqs']) @@ -77,7 +77,7 @@ def parse_line(req_line): else: name = '' specifier = '' - return Requirement(name, specifier, markers, comment) + return Requirement(name, '', specifier, markers, comment) def to_content(reqs, marker_sep=';', line_prefix='', prefix=True): diff --git a/openstack_requirements/tests/test_edit_constraint.py b/openstack_requirements/tests/test_edit_constraint.py index 3caef665a2..1f83f632d2 100644 --- a/openstack_requirements/tests/test_edit_constraint.py +++ b/openstack_requirements/tests/test_edit_constraint.py @@ -45,7 +45,7 @@ class TestEdit(testtools.TestCase): reqs = {} res = edit.edit(reqs, 'foo', 'foo==1.2') self.assertEqual(requirement.Requirements( - [requirement.Requirement('', '', '', 'foo==1.2')]), res) + [requirement.Requirement('', '', '', '', 'foo==1.2')]), res) def test_delete(self): reqs = requirement.parse('foo==1.2\n') @@ -56,10 +56,10 @@ class TestEdit(testtools.TestCase): reqs = requirement.parse('foo==1.2\n') res = edit.edit(reqs, 'foo', 'foo==1.3') self.assertEqual(requirement.Requirements( - [requirement.Requirement('', '', '', 'foo==1.3')]), res) + [requirement.Requirement('', '', '', '', 'foo==1.3')]), res) def test_replace_many(self): reqs = requirement.parse('foo==1.2;p\nfoo==1.3;q') res = edit.edit(reqs, 'foo', 'foo==1.3') self.assertEqual(requirement.Requirements( - [requirement.Requirement('', '', '', 'foo==1.3')]), res) + [requirement.Requirement('', '', '', '', 'foo==1.3')]), res) diff --git a/openstack_requirements/tests/test_project.py b/openstack_requirements/tests/test_project.py index 111bfb0eb7..ba1df5b360 100644 --- a/openstack_requirements/tests/test_project.py +++ b/openstack_requirements/tests/test_project.py @@ -200,9 +200,10 @@ class TestMergeSetupCfg(testtools.TestCase): console_scripts = foo = bar:quux """) - blank = requirement.Requirement('', '', '', '') - r1 = requirement.Requirement('b', '>=1', "python_version=='2.7'", '') - r2 = requirement.Requirement('d', '', '', '# BSD') + blank = requirement.Requirement('', '', '', '', '') + r1 = requirement.Requirement( + 'b', '', '>=1', "python_version=='2.7'", '') + r2 = requirement.Requirement('d', '', '', '', '# BSD') reqs = { 'a': requirement.Requirements([blank, r1]), 'c': requirement.Requirements([blank, r2])} diff --git a/openstack_requirements/tests/test_requirement.py b/openstack_requirements/tests/test_requirement.py index f2f6926343..eb530feb18 100644 --- a/openstack_requirements/tests/test_requirement.py +++ b/openstack_requirements/tests/test_requirement.py @@ -25,32 +25,33 @@ class TestParseRequirement(testtools.TestCase): scenarios = [ ('package', dict( line='swift', - req=requirement.Requirement('swift', '', '', ''))), + req=requirement.Requirement('swift', '', '', '', ''))), ('specifier', dict( line='alembic>=0.4.1', - req=requirement.Requirement('alembic', '>=0.4.1', '', ''))), + req=requirement.Requirement('alembic', '', '>=0.4.1', '', ''))), ('specifiers', dict( line='alembic>=0.4.1,!=1.1.8', - req=requirement.Requirement('alembic', '!=1.1.8,>=0.4.1', '', ''))), + req=requirement.Requirement('alembic', '', '!=1.1.8,>=0.4.1', '', + ''))), ('comment-only', dict( line='# foo', - req=requirement.Requirement('', '', '', '# foo'))), + req=requirement.Requirement('', '', '', '', '# foo'))), ('comment', dict( line='Pint>=0.5 # BSD', - req=requirement.Requirement('Pint', '>=0.5', '', '# BSD'))), + req=requirement.Requirement('Pint', '', '>=0.5', '', '# BSD'))), ('comment-with-semicolon', dict( line='Pint>=0.5 # BSD;fred', - req=requirement.Requirement('Pint', '>=0.5', '', '# BSD;fred'))), + req=requirement.Requirement('Pint', '', '>=0.5', '', '# BSD;fred'))), ('case', dict( line='Babel>=1.3', - req=requirement.Requirement('Babel', '>=1.3', '', ''))), + req=requirement.Requirement('Babel', '', '>=1.3', '', ''))), ('markers', dict( line="pywin32;sys_platform=='win32'", - req=requirement.Requirement('pywin32', '', "sys_platform=='win32'", - ''))), + req=requirement.Requirement('pywin32', '', '', + "sys_platform=='win32'", ''))), ('markers-with-comment', dict( line="Sphinx<=1.2; python_version=='2.7'# Sadface", - req=requirement.Requirement('Sphinx', '<=1.2', + req=requirement.Requirement('Sphinx', '', '<=1.2', "python_version=='2.7'", '# Sadface')))] def test_parse(self): @@ -76,7 +77,7 @@ class TestToContent(testtools.TestCase): def test_smoke(self): reqs = requirement.to_content(requirement.Requirements( [requirement.Requirement( - 'foo', '<=1', "python_version=='2.7'", '# BSD')]), + 'foo', '', '<=1', "python_version=='2.7'", '# BSD')]), marker_sep='!') self.assertEqual( ''.join(requirement._REQS_HEADER diff --git a/openstack_requirements/tests/test_update.py b/openstack_requirements/tests/test_update.py index 94ce34370b..1d02b1e718 100644 --- a/openstack_requirements/tests/test_update.py +++ b/openstack_requirements/tests/test_update.py @@ -257,9 +257,10 @@ class TestSyncRequirementsFile(testtools.TestCase): actions, reqs = update._sync_requirements_file( global_reqs, project_reqs, 'f', False, False, False) self.assertEqual(requirement.Requirements([ - requirement.Requirement('foo', '<2', "python_version=='2.7'", ''), requirement.Requirement( - 'foo', '>1', "python_version!='2.7'", '')]), + 'foo', '', '<2', "python_version=='2.7'", ''), + requirement.Requirement( + 'foo', '', '>1', "python_version!='2.7'", '')]), reqs) self.assertEqual(project.StdOut( " foo " @@ -284,9 +285,12 @@ class TestSyncRequirementsFile(testtools.TestCase): actions, reqs = update._sync_requirements_file( global_reqs, project_reqs, 'f', False, False, False) self.assertEqual(requirement.Requirements([ - requirement.Requirement('foo', '<2', "python_version=='2.7'", ''), - requirement.Requirement('foo', '>1', "python_version!='2.7'", ''), - requirement.Requirement('', '', '', "# mumbo gumbo")]), + requirement.Requirement( + 'foo', '', '<2', "python_version=='2.7'", ''), + requirement.Requirement( + 'foo', '', '>1', "python_version!='2.7'", ''), + requirement.Requirement( + '', '', '', '', "# mumbo gumbo")]), reqs) self.assertThat(actions, matchers.HasLength(0)) @@ -305,9 +309,12 @@ class TestSyncRequirementsFile(testtools.TestCase): actions, reqs = update._sync_requirements_file( global_reqs, project_reqs, 'f', False, False, False) self.assertEqual(requirement.Requirements([ - requirement.Requirement('foo', '<2', "python_version=='2.7'", ''), - requirement.Requirement('foo', '>1', "python_version!='2.7'", ''), - requirement.Requirement('', '', '', "# mumbo gumbo")]), + requirement.Requirement( + 'foo', '', '<2', "python_version=='2.7'", ''), + requirement.Requirement( + 'foo', '', '>1', "python_version!='2.7'", ''), + requirement.Requirement( + '', '', '', '', "# mumbo gumbo")]), reqs) self.assertEqual(project.StdOut( " foo<1.8;python_version=='2.7' -> " @@ -331,9 +338,10 @@ class TestSyncRequirementsFile(testtools.TestCase): actions, reqs = update._sync_requirements_file( global_reqs, project_reqs, 'f', False, False, False) self.assertEqual(requirement.Requirements([ - requirement.Requirement('foo', '<2', "python_version=='2.7'", ''), requirement.Requirement( - 'foo', '>1', "python_version!='2.7'", '')]), + 'foo', '', '<2', "python_version=='2.7'", ''), + requirement.Requirement( + 'foo', '', '>1', "python_version!='2.7'", '')]), reqs) self.assertThat(actions, matchers.HasLength(0)) @@ -350,7 +358,7 @@ class TestSyncRequirementsFile(testtools.TestCase): actions, reqs = update._sync_requirements_file( global_reqs, project_reqs, 'f', False, False, False) self.assertEqual(requirement.Requirements([ - requirement.Requirement('foo', '>1', "", '')]), + requirement.Requirement('foo', '', '>1', "", '')]), reqs) self.assertEqual(project.StdOut( " foo<2;python_version=='2.7' -> foo>1\n"), actions[2])