Merge "Ignore index URL lines in requirements.txt files"
This commit is contained in:
commit
c9a183b2c5
@ -102,6 +102,10 @@ def parse_requirements(requirements_files=None, strip_markers=False):
|
||||
if (not line.strip()) or line.startswith('#'):
|
||||
continue
|
||||
|
||||
# Ignore index URL lines
|
||||
if re.match(r'^\s*(-i|--index-url|--extra-index-url).*', line):
|
||||
continue
|
||||
|
||||
# Handle nested requirements files such as:
|
||||
# -r other-requirements.txt
|
||||
if line.startswith('-r'):
|
||||
|
@ -486,6 +486,19 @@ class TestPresenceOfGit(base.BaseTestCase):
|
||||
self.assertEqual(False, git._git_is_installed())
|
||||
|
||||
|
||||
class TestIndexInRequirements(base.BaseTestCase):
|
||||
|
||||
def test_index_in_requirement(self):
|
||||
tempdir = tempfile.mkdtemp()
|
||||
requirements = os.path.join(tempdir, 'requirements.txt')
|
||||
with open(requirements, 'w') as f:
|
||||
f.write('-i https://myindex.local')
|
||||
f.write(' --index-url https://myindex.local')
|
||||
f.write(' --extra-index-url https://myindex.local')
|
||||
result = packaging.parse_requirements([requirements])
|
||||
self.assertEqual([], result)
|
||||
|
||||
|
||||
class TestNestedRequirements(base.BaseTestCase):
|
||||
|
||||
def test_nested_requirement(self):
|
||||
|
Loading…
Reference in New Issue
Block a user