Commit 89f044d4 authored by Reinout van Rees's avatar Reinout van Rees

Adjusted the test so that it also works when you're testing with an older...

Adjusted the test so that it also works when you're testing with an older setuptools version and there's a new one on pypi.
In that case, the _call_easy_install call will really try to install setuptools first and execute other code paths than the test cares for.
A cleaner way does not seem possible as the easy_install code is really intertwined.
parent 6d9c87e9
...@@ -4,7 +4,7 @@ Installing setuptools/distribute ...@@ -4,7 +4,7 @@ Installing setuptools/distribute
Some initial test setup: Some initial test setup:
>>> import sys >>> import sys
>>> import zc.buildout.easy_install >>> import zc.buildout
>>> dest = tmpdir('sample-install') >>> dest = tmpdir('sample-install')
Setuptools (0.6something) is packaged as an ``.egg``. So when installing it, Setuptools (0.6something) is packaged as an ``.egg``. So when installing it,
...@@ -28,6 +28,21 @@ be printed. We call ``_call_easy_install()`` directly and get an error ...@@ -28,6 +28,21 @@ be printed. We call ``_call_easy_install()`` directly and get an error
because of a non-existing tarball, but that's the OK for this corner case because of a non-existing tarball, but that's the OK for this corner case
test: we only want to test that ``_get_dist()`` isn't getting called: test: we only want to test that ``_get_dist()`` isn't getting called:
>>> class MockDist(object):
... def __str__(self):
... return 'nonexisting.tgz'
... @property
... def project_name(self):
... # Testing corner case: there *is* actually
... # a newer setuptools package on pypi than we
... # are running with, so it really installs it
... # and compares project_name. We're past the
... # point that we're testing, so we just raise
... # the normally expected error.
... raise zc.buildout.UserError(
... "Couldn't install: nonexisting.tgz")
>>> dist = MockDist()
>>> installer = zc.buildout.easy_install.Installer( >>> installer = zc.buildout.easy_install.Installer(
... dest=dest, ... dest=dest,
... links=[link_server], ... links=[link_server],
...@@ -35,8 +50,7 @@ test: we only want to test that ``_get_dist()`` isn't getting called: ...@@ -35,8 +50,7 @@ test: we only want to test that ``_get_dist()`` isn't getting called:
... executable=sys.executable, ... executable=sys.executable,
... always_unzip=True) ... always_unzip=True)
>>> installer._get_dist = mock_get_dist >>> installer._get_dist = mock_get_dist
>>> installer._call_easy_install('setuptools', None, dest, >>> installer._call_easy_install('setuptools', None, dest, dist)
... 'nonexisting.tgz')
Traceback (most recent call last): Traceback (most recent call last):
... ...
UserError: Couldn't install: nonexisting.tgz UserError: Couldn't install: nonexisting.tgz
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment