From 83ca4fbbb3bdf26eafa72c433e3e8d1ae50be8ab Mon Sep 17 00:00:00 2001 From: Alexandros Tzannes Date: Thu, 19 Jul 2018 14:10:20 -0400 Subject: [PATCH 1/8] Add test for setup.py::dependency-link field --- tests/integration/test_install_twists.py | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index d2cdd9aa..f6d8706e 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -57,6 +57,48 @@ zip_safe=False assert "six" in p.lockfile["default"] +@pytest.mark.install +@pytest.mark.local +@pytest.mark.needs_internet +@flaky +def test_local_dependency_links_install(PipenvInstance, pypi): + """Ensure dependency_links are parsed and installed (needed for private repo dependencies). + """ + def make_setup(pipenv_instance, deplink): + setup_py = os.path.join(pipenv_instance.path, "setup.py") + with open(setup_py, "w") as fh: + contents = """ +from setuptools import setup + +setup( + name='testdeplinks', + version='0.1', + packages=[], + install_requires=[ + 'test-private-dependency' + ], + dependency_links=[ + '{0}' + ] +) + """.strip().format(deplink) + fh.write(contents) + + def test_deplink(pipenv_instance, deplink): + make_setup(pipenv_instance, deplink) + c = pipenv_instance.pipenv("install -e .") + assert c.return_code == 0 + assert "test-private-dependency" in pipenv_instance.lockfile["default"] + assert "version" in pipenv_instance.lockfile["default"]["test-private-dependency"] + assert "0.1" in pipenv_instance.lockfile["default"]["test-private-dependency"]["version"] + + with PipenvInstance(pypi=pypi, chdir=True) as p: + test_deplink(p, 'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') + + with PipenvInstance(pypi=pypi, chdir=True) as p: + test_deplink(p, 'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') + + @pytest.mark.e @pytest.mark.install @pytest.mark.skip(reason="this doesn't work on windows") From e47fd53f9538528914fc273e6a9056b529baba4d Mon Sep 17 00:00:00 2001 From: Alexandros Tzannes Date: Fri, 3 Aug 2018 13:04:16 -0700 Subject: [PATCH 2/8] [fixup] skip the git+ssh deplink test if the git+https test works on Build Kite --- tests/integration/test_install_twists.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index f6d8706e..7c06696d 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -95,8 +95,8 @@ setup( with PipenvInstance(pypi=pypi, chdir=True) as p: test_deplink(p, 'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') - with PipenvInstance(pypi=pypi, chdir=True) as p: - test_deplink(p, 'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') + # with PipenvInstance(pypi=pypi, chdir=True) as p: + # test_deplink(p, 'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') @pytest.mark.e From f1cb2287ab17d340e7214ef939e4f1713a57b20c Mon Sep 17 00:00:00 2001 From: Alexandros Tzannes Date: Fri, 3 Aug 2018 13:27:51 -0700 Subject: [PATCH 3/8] Add -v flag to get better insight when it fails --- tests/integration/test_install_twists.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index 7c06696d..636d10ee 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -86,7 +86,7 @@ setup( def test_deplink(pipenv_instance, deplink): make_setup(pipenv_instance, deplink) - c = pipenv_instance.pipenv("install -e .") + c = pipenv_instance.pipenv("install -v -e .") assert c.return_code == 0 assert "test-private-dependency" in pipenv_instance.lockfile["default"] assert "version" in pipenv_instance.lockfile["default"]["test-private-dependency"] From 0e7ddbccf3beab3bb3c92c55bcbd2ec2ca6f732a Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sun, 5 Aug 2018 02:49:18 -0400 Subject: [PATCH 4/8] Enable dependency link processing - Use `PIP_PROCESS_DEPENDENCY_LINKS` to toggle the processing of dependency links --- tests/integration/test_install_twists.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index 636d10ee..d357805f 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -92,7 +92,8 @@ setup( assert "version" in pipenv_instance.lockfile["default"]["test-private-dependency"] assert "0.1" in pipenv_instance.lockfile["default"]["test-private-dependency"]["version"] - with PipenvInstance(pypi=pypi, chdir=True) as p: + with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p: + os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1' test_deplink(p, 'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') # with PipenvInstance(pypi=pypi, chdir=True) as p: From 210a9d46fb4fcebe66783e2dfddeec6f0df15a6e Mon Sep 17 00:00:00 2001 From: Alexandros Tzannes Date: Mon, 6 Aug 2018 10:04:16 -0700 Subject: [PATCH 5/8] Add back git+ssh version of dep-links test See if it fails n build Kite --- tests/integration/test_install_twists.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index d357805f..ab41906a 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -96,8 +96,9 @@ setup( os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1' test_deplink(p, 'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') - # with PipenvInstance(pypi=pypi, chdir=True) as p: - # test_deplink(p, 'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') + with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p: + os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1' + test_deplink(p, 'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') @pytest.mark.e From 3cc02ebd5d2e2795670853316807607c2b8841cc Mon Sep 17 00:00:00 2001 From: Alexandros Tzannes Date: Mon, 6 Aug 2018 10:30:04 -0700 Subject: [PATCH 6/8] Break dependency-links test into two separate tests Use helper functions to reduce code duplication since these two tests are quasi-identical --- tests/integration/test_install_twists.py | 61 +++++++++++++++--------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index ab41906a..5de15a2a 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -57,17 +57,10 @@ zip_safe=False assert "six" in p.lockfile["default"] -@pytest.mark.install -@pytest.mark.local -@pytest.mark.needs_internet -@flaky -def test_local_dependency_links_install(PipenvInstance, pypi): - """Ensure dependency_links are parsed and installed (needed for private repo dependencies). - """ - def make_setup(pipenv_instance, deplink): - setup_py = os.path.join(pipenv_instance.path, "setup.py") - with open(setup_py, "w") as fh: - contents = """ +def helper_dependency_links_install_make_setup(pipenv_instance, deplink): + setup_py = os.path.join(pipenv_instance.path, "setup.py") + with open(setup_py, "w") as fh: + contents = """ from setuptools import setup setup( @@ -81,24 +74,48 @@ setup( '{0}' ] ) - """.strip().format(deplink) - fh.write(contents) + """.strip().format(deplink) + fh.write(contents) - def test_deplink(pipenv_instance, deplink): - make_setup(pipenv_instance, deplink) - c = pipenv_instance.pipenv("install -v -e .") - assert c.return_code == 0 - assert "test-private-dependency" in pipenv_instance.lockfile["default"] - assert "version" in pipenv_instance.lockfile["default"]["test-private-dependency"] - assert "0.1" in pipenv_instance.lockfile["default"]["test-private-dependency"]["version"] +def helper_dependency_links_install_test(pipenv_instance, deplink): + helper_dependency_links_install_make_setup(pipenv_instance, deplink) + c = pipenv_instance.pipenv("install -v -e .") + assert c.return_code == 0 + assert "test-private-dependency" in pipenv_instance.lockfile["default"] + assert "version" in pipenv_instance.lockfile["default"]["test-private-dependency"] + assert "0.1" in pipenv_instance.lockfile["default"]["test-private-dependency"]["version"] + + +@pytest.mark.install +@pytest.mark.local +@pytest.mark.needs_internet +@flaky +def test_https_dependency_links_install(PipenvInstance, pypi): + """Ensure dependency_links are parsed and installed (needed for private repo dependencies). + """ with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p: os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1' - test_deplink(p, 'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') + helper_dependency_links_install_test( + p, + 'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1' + ) + +@pytest.mark.install +@pytest.mark.local +@pytest.mark.needs_internet +@pytest.mark.needs_github_ssh +@flaky +def test_ssh_dependency_links_install(PipenvInstance, pypi): + """Ensure dependency_links are parsed and installed (needed for private repo dependencies). + """ with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p: os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1' - test_deplink(p, 'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1') + helper_dependency_links_install_test( + p, + 'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1' + ) @pytest.mark.e From dd3b2108628ed8409524e0b9f76861f6a0d372d1 Mon Sep 17 00:00:00 2001 From: Alexandros Tzannes Date: Mon, 6 Aug 2018 10:41:16 -0700 Subject: [PATCH 7/8] Wrap two tests and helpers in a class --- tests/integration/test_install_twists.py | 89 ++++++++++++------------ 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index 5de15a2a..d9e571e1 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -57,10 +57,17 @@ zip_safe=False assert "six" in p.lockfile["default"] -def helper_dependency_links_install_make_setup(pipenv_instance, deplink): - setup_py = os.path.join(pipenv_instance.path, "setup.py") - with open(setup_py, "w") as fh: - contents = """ +class TestDependencyLinks(object): + """Ensure dependency_links are parsed and installed. + + This is needed for private repo dependencies. + """ + + @staticmethod + def helper_dependency_links_install_make_setup(pipenv_instance, deplink): + setup_py = os.path.join(pipenv_instance.path, "setup.py") + with open(setup_py, "w") as fh: + contents = """ from setuptools import setup setup( @@ -74,48 +81,44 @@ setup( '{0}' ] ) - """.strip().format(deplink) - fh.write(contents) + """.strip().format(deplink) + fh.write(contents) + @staticmethod + def helper_dependency_links_install_test(pipenv_instance, deplink): + TestDependencyLinks.helper_dependency_links_install_make_setup(pipenv_instance, deplink) + c = pipenv_instance.pipenv("install -v -e .") + assert c.return_code == 0 + assert "test-private-dependency" in pipenv_instance.lockfile["default"] + assert "version" in pipenv_instance.lockfile["default"]["test-private-dependency"] + assert "0.1" in pipenv_instance.lockfile["default"]["test-private-dependency"]["version"] -def helper_dependency_links_install_test(pipenv_instance, deplink): - helper_dependency_links_install_make_setup(pipenv_instance, deplink) - c = pipenv_instance.pipenv("install -v -e .") - assert c.return_code == 0 - assert "test-private-dependency" in pipenv_instance.lockfile["default"] - assert "version" in pipenv_instance.lockfile["default"]["test-private-dependency"] - assert "0.1" in pipenv_instance.lockfile["default"]["test-private-dependency"]["version"] + @pytest.mark.install + @pytest.mark.local + @pytest.mark.needs_internet + @flaky + def test_https_dependency_links_install(self, PipenvInstance, pypi): + """Ensure dependency_links are parsed and installed (needed for private repo dependencies). + """ + with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p: + os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1' + TestDependencyLinks.helper_dependency_links_install_test( + p, + 'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1' + ) - -@pytest.mark.install -@pytest.mark.local -@pytest.mark.needs_internet -@flaky -def test_https_dependency_links_install(PipenvInstance, pypi): - """Ensure dependency_links are parsed and installed (needed for private repo dependencies). - """ - with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p: - os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1' - helper_dependency_links_install_test( - p, - 'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1' - ) - - -@pytest.mark.install -@pytest.mark.local -@pytest.mark.needs_internet -@pytest.mark.needs_github_ssh -@flaky -def test_ssh_dependency_links_install(PipenvInstance, pypi): - """Ensure dependency_links are parsed and installed (needed for private repo dependencies). - """ - with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p: - os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1' - helper_dependency_links_install_test( - p, - 'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1' - ) + @pytest.mark.install + @pytest.mark.local + @pytest.mark.needs_internet + @pytest.mark.needs_github_ssh + @flaky + def test_ssh_dependency_links_install(self, PipenvInstance, pypi): + with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p: + os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1' + TestDependencyLinks.helper_dependency_links_install_test( + p, + 'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1' + ) @pytest.mark.e From 86bbec18d9a6dbd58be5e15bf5c47bbd74c8d69b Mon Sep 17 00:00:00 2001 From: Alexandros Tzannes Date: Mon, 6 Aug 2018 10:44:10 -0700 Subject: [PATCH 8/8] Factor-out decorators for class tests --- tests/integration/test_install_twists.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index d9e571e1..8653e2c0 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -57,6 +57,10 @@ zip_safe=False assert "six" in p.lockfile["default"] +@pytest.mark.install +@pytest.mark.local +@pytest.mark.needs_internet +@flaky class TestDependencyLinks(object): """Ensure dependency_links are parsed and installed. @@ -93,10 +97,6 @@ setup( assert "version" in pipenv_instance.lockfile["default"]["test-private-dependency"] assert "0.1" in pipenv_instance.lockfile["default"]["test-private-dependency"]["version"] - @pytest.mark.install - @pytest.mark.local - @pytest.mark.needs_internet - @flaky def test_https_dependency_links_install(self, PipenvInstance, pypi): """Ensure dependency_links are parsed and installed (needed for private repo dependencies). """ @@ -107,11 +107,7 @@ setup( 'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1' ) - @pytest.mark.install - @pytest.mark.local - @pytest.mark.needs_internet @pytest.mark.needs_github_ssh - @flaky def test_ssh_dependency_links_install(self, PipenvInstance, pypi): with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p: os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1'