Adds a special case for index urls similar to how comments are captured. This should avoid breaking ordering when --index-url (-i) and/or --extra-index-url are used. Also adds a relevant test to cover this case. Closes #612.

This commit is contained in:
Ryan Miguel 2022-10-18 16:03:57 -07:00
parent 4dcb74a498
commit 87001a2778
2 changed files with 33 additions and 0 deletions

View file

@ -99,6 +99,27 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
PASS,
b'a=2.0.0 \\\n --hash=sha256:abcd\nb==1.0.0\n',
),
(
b'# Bar\n'
b'--extra-index-url http://dist.repoze.org/zope2/2.10/simple\n'
b'zopelib2\n'
b'# Foo\n'
b'-i http://dist.repoze.org/zope2/2.10/simple\n'
b'zopelib1\n'
b'# Baz\n'
b'--index-url http://dist.repoze.org/zope2/2.10/simple\n'
b'zopelib3',
FAIL,
b'-i http://dist.repoze.org/zope2/2.10/simple\n'
b'--index-url http://dist.repoze.org/zope2/2.10/simple\n'
b'--extra-index-url http://dist.repoze.org/zope2/2.10/simple\n'
b'# Foo\n'
b'zopelib1\n'
b'# Bar\n'
b'zopelib2\n'
b'# Baz\n'
b'zopelib3\n',
),
),
)
def test_integration(input_s, expected_retval, output, tmpdir):