pytest-dev / pytest-runner

MIT License
56 stars 21 forks source link

pytest is causing dependency_links to be ignored #31

Closed dagostinelli closed 7 years ago

dagostinelli commented 7 years ago

(I originally filed this here, but was asked to move it. I've re-written it a bit now knowing that it might be pytest-runner

When using a setup.cfg, pytest can take over as unit test runner from the built-in stuff.

setup.cfg

[aliases]
test=pytest

When doing this and then when I run python setup.py test, I expect my unit tests to run and dependencies to get installed. Instead, PyPi is getting searched and dependency_links is getting ignored.

setup.py

from setuptools import setup, find_packages

setup(
    name='MyApp',
    version='1.0',
    maintainer='Me',
    maintainer_email='me@somewhere.com',
    url='http://www.somewhere.com',
    packages = find_packages(),
    install_requires=['myotherproject==1.0'],
    setup_requires=['pytest-runner', 'pytest'],
    tests_require=['pytest', 'pytest-asyncio', 'myotherproject==1.0'],
    test_suite='tests',
    dependency_links=['git+ssh://myname@myserver:/git/path/to/stuff/myotherproject@master#egg=myotherproject-1.0'],
    include_package_data=True,
)

When I use the above with python setup.py test, myotherproject gets installed into .eggs.

If I then add a setup.cfg file like so to activate pytest:

setup.cfg

[aliases]
test=pytest

Then python setup.py test ignores dependency_links and attempts to search pypi for the myotherproject (and naturally it can't find it and errors out)

Then I just comment out the lines in setup.cfg and re-run python setup.py test and it works again.

setup.cfg

#[aliases]
#test=pytest
benoit-pierre commented 7 years ago

Can you confirm you're using pytest-runner==2.12, and that it works fine when using pytest-runner==2.11?

@jaraco: I'll make a PR with this patch

 ptr.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git i/ptr.py w/ptr.py
index ecba60c..bcdfc7d 100644
--- i/ptr.py
+++ w/ptr.py
@@ -173,7 +173,7 @@ class PyTest(orig.test):
        dist = CustomizedDist()
        for attr in 'allow_hosts index_url'.split():
            setattr(dist, attr, getattr(self, attr))
-       for attr in 'install_requires tests_require extras_require'.split():
+       for attr in 'dependency_links install_requires tests_require extras_require'.split():
            setattr(dist, attr, getattr(self.distribution, attr))
        installed_dists = self.install_dists(dist)
        if self.dry_run:
benoit-pierre commented 7 years ago

Forgot to mention, when using pytest-runner==2.11, you'll need setuptools<36.4.0.