From 31a4a75c9813196cfb6ee5dc0e2d68fba52d0ff9 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Tue, 17 Apr 2018 01:27:28 -0400 Subject: [PATCH] Sort items before comparison Signed-off-by: Dan Ryan --- tests/integration/test_project.py | 66 ++++++------------------------- 1 file changed, 11 insertions(+), 55 deletions(-) diff --git a/tests/integration/test_project.py b/tests/integration/test_project.py index f3efdd2d..4e8fe44a 100644 --- a/tests/integration/test_project.py +++ b/tests/integration/test_project.py @@ -2,16 +2,13 @@ import pytest import os from pipenv.project import Project -import unittest @pytest.mark.project @pytest.mark.sources -def test_get_cached_source(PipenvInstance, pypi): +@pytest.mark.parametrize('lock_first', [True, False]) +def test_get_source(PipenvInstance, pypi, lock_first): with PipenvInstance(pypi=pypi, chdir=True) as p: - - # Make sure unparseable packages don't wind up in the pipfile - # Escape $ for shell input with open(p.pipfile_path, 'w') as f: contents = """ [[source]] @@ -31,8 +28,11 @@ six = {{version = "*", index = "pypi"}} [dev-packages] """.format(os.environ['PIPENV_TEST_INDEX']).strip() f.write(contents) - c = p.pipenv('lock') - assert c.return_code == 0 + + 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'], @@ -45,51 +45,7 @@ six = {{version = "*", index = "pypi"}} source = source[0] assert source['name'] == name assert source['url'] == url - assert unittest.assertDictEqual(source, project.get_source(name=name)) - assert unittest.assertDictEqual(source, project.get_source(url=url)) - assert unittest.assertDictEqual(source, project.find_source(name)) - assert unittest.assertDictEqual(source, project.find_source(url)) - - -@pytest.mark.project -@pytest.mark.sources -def test_get_uncached_source(PipenvInstance, pypi): - with PipenvInstance(pypi=pypi, chdir=True) as p: - - # Make sure unparseable packages don't wind up in the pipfile - # Escape $ for shell input - 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) - 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 unittest.assertDictEqual(source, project.get_source(name=name)) - assert unittest.assertDictEqual(source, project.get_source(url=url)) - assert unittest.assertDictEqual(source, project.find_source(name)) - assert unittest.assertDictEqual(source, project.find_source(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())