Files
pipenv/tests/integration/test_project.py
T
Dan Ryan 31a4a75c98 Sort items before comparison
Signed-off-by: Dan Ryan <dan@danryan.co>
2018-04-17 01:52:16 -04:00

52 lines
1.6 KiB
Python

# -*- coding=utf-8 -*-
import pytest
import os
from pipenv.project import Project
@pytest.mark.project
@pytest.mark.sources
@pytest.mark.parametrize('lock_first', [True, False])
def test_get_source(PipenvInstance, pypi, lock_first):
with PipenvInstance(pypi=pypi, chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
contents = """
[[source]]
url = "{0}"
verify_ssl = false
name = "testindex"
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = "true"
name = "pypi"
[packages]
pytz = "*"
six = {{version = "*", index = "pypi"}}
[dev-packages]
""".format(os.environ['PIPENV_TEST_INDEX']).strip()
f.write(contents)
if lock_first:
# force source to be cached
c = p.pipenv('lock')
assert c.return_code == 0
project = Project()
sources = [
['pypi', 'https://pypi.python.org/simple'],
['testindex', os.environ.get('PIPENV_TEST_INDEX')]
]
for src in sources:
name, url = src
source = [s for s in project.pipfile_sources if s.get('name') == name]
assert source
source = source[0]
assert source['name'] == name
assert source['url'] == url
assert sorted(source.items()) == sorted(project.get_source(name=name).items())
assert sorted(source.items()) == sorted(project.get_source(url=url).items())
assert sorted(source.items()) == sorted(project.find_source(name).items())
assert sorted(source.items()) == sorted(project.find_source(url).items())