1+ from __future__ import absolute_import
2+
13import os
24import sys
35
46import pytest
57from mock import patch
6- import pytest
78
89from 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." )
1313def 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