Skip to content

Commit 19a1812

Browse files
committed
Merge pull request pytest-dev#47 from ahlmss/fix_pyinstall_unit
Fix for the pyinstall unit test
2 parents f761f8b + bbf62f8 commit 19a1812

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎pkglib/pkglib/setuptools/command/base.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def maybe_add_simple_index(self, url):
206206

207207
# DevPI. TODO: use pip.conf / pydistutils.cfg for all of this
208208
elif CONFIG.pypi_variant == 'devpi':
209-
url += '/root/pypi/+simple/'
209+
url += '/+simple/'
210210
return url
211211

212212
def get_site_packages(self):

‎pkglib/setup.cfg‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ install_requires =
3838
setuptools
3939
pkglib_util
4040
pip>=0.7.2
41-
zc.buildout
41+
zc.buildout>=1.5.2, <1.6.0
4242
termcolor>=1.1.0
4343
importlib>=1.0.2
4444
argparse>=1.2.1

‎pkglib/tests/unit/test_pyinstall_unit.py‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
from __future__ import absolute_import
2+
13
import os
24
import sys
35

46
import pytest
57
from mock import patch
6-
import pytest
78

89
from pkglib.scripts import pyinstall
10+
from zc.buildout.easy_install import _get_index
911

1012

11-
@pytest.mark.skipif('TRAVIS' in os.environ,
12-
reason="Our monkey patch doesn't work with the version of setuptools on Travis. FIXME.")
1313
def test_pyinstall_respects_i_flag():
1414
"""Ensure that pyinstall allows us to override the PyPI URL with -i,
1515
even if it's already set in the config.
@@ -19,7 +19,8 @@ def test_pyinstall_respects_i_flag():
1919
package_name = "some-package"
2020
expected_url = "%s/%s/" % (pypi_url, package_name)
2121

22-
class OpenedCorrectUrl(Exception): pass
22+
class OpenedCorrectUrl(Exception):
23+
pass
2324

2425
def fake_urlopen(request, *args, **kwargs):
2526
assert request.get_full_url() == expected_url
@@ -28,11 +29,15 @@ def fake_urlopen(request, *args, **kwargs):
2829
# raise an exception so we terminate here.
2930
raise OpenedCorrectUrl()
3031

31-
with patch('setuptools.package_index.urllib2.urlopen', fake_urlopen):
32+
def get_index(*args, **kwargs):
33+
index = _get_index(*args, **kwargs)
34+
index.opener = fake_urlopen
35+
return index
36+
37+
with patch('zc.buildout.easy_install._get_index', get_index):
3238
# Call pyinstall with the -i flag.
3339
args = ['pyinstall', '-i', pypi_url, package_name]
3440
with patch.object(sys, 'argv', args):
35-
3641
try:
3742
pyinstall.main()
3843
except OpenedCorrectUrl:

0 commit comments

Comments
 (0)