diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2010-05-15 07:33:37 -1000 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2010-05-15 07:33:37 -1000 |
commit | 1fc291ffa0bdddb8869224a760f3af7ef5a45cf5 (patch) | |
tree | ca6c6b1e70f74b169bd6167d5c2aa81fbddb693d /setuptools/tests/test_easy_install.py | |
parent | 4353f3f6eaabc04859bcbd592c58df985bd2ad3b (diff) | |
parent | de6e3bcc3c77bff17a6609b31bc1b6a9212bbd88 (diff) | |
download | external_python_setuptools-1fc291ffa0bdddb8869224a760f3af7ef5a45cf5.tar.gz external_python_setuptools-1fc291ffa0bdddb8869224a760f3af7ef5a45cf5.tar.bz2 external_python_setuptools-1fc291ffa0bdddb8869224a760f3af7ef5a45cf5.zip |
Merged Fix for #151
--HG--
branch : distribute
extra : rebase_source : 7f7f9c64a26c6110096387b9862e06455c49f2ec
Diffstat (limited to 'setuptools/tests/test_easy_install.py')
-rw-r--r-- | setuptools/tests/test_easy_install.py | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 95909ca7..e02798c6 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -2,8 +2,13 @@ """ import sys import os, shutil, tempfile, unittest +import site +from StringIO import StringIO from setuptools.command.easy_install import easy_install, get_script_args, main +from setuptools.command.easy_install import PthDistributions +from setuptools.command import easy_install as easy_install_pkg from setuptools.dist import Distribution +from pkg_resources import Distribution as PRDistribution class FakeDist(object): def get_entry_map(self, group): @@ -90,3 +95,94 @@ class TestEasyInstallTest(unittest.TestCase): os.chdir(old_wd) shutil.rmtree(dir) + def test_no_find_links(self): + # new option '--no-find-links', that blocks find-links added at + # the project level + dist = Distribution() + cmd = easy_install(dist) + cmd.check_pth_processing = lambda : True + cmd.no_find_links = True + cmd.find_links = ['link1', 'link2'] + cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok') + cmd.args = ['ok'] + cmd.ensure_finalized() + self.assertEquals(cmd.package_index.scanned_urls, {}) + + # let's try without it (default behavior) + cmd = easy_install(dist) + cmd.check_pth_processing = lambda : True + cmd.find_links = ['link1', 'link2'] + cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok') + cmd.args = ['ok'] + cmd.ensure_finalized() + keys = cmd.package_index.scanned_urls.keys() + keys.sort() + self.assertEquals(keys, ['link1', 'link2']) + + +class TestPTHFileWriter(unittest.TestCase): + def test_add_from_cwd_site_sets_dirty(self): + '''a pth file manager should set dirty + if a distribution is in site but also the cwd + ''' + pth = PthDistributions('does-not_exist', [os.getcwd()]) + self.assert_(not pth.dirty) + pth.add(PRDistribution(os.getcwd())) + self.assert_(pth.dirty) + + def test_add_from_site_is_ignored(self): + pth = PthDistributions('does-not_exist', ['/test/location/does-not-have-to-exist']) + self.assert_(not pth.dirty) + pth.add(PRDistribution('/test/location/does-not-have-to-exist')) + self.assert_(not pth.dirty) + + +class TestUserInstallTest(unittest.TestCase): + + def setUp(self): + self.dir = tempfile.mkdtemp() + setup = os.path.join(self.dir, 'setup.py') + f = open(setup, 'w') + f.write(SETUP_PY) + f.close() + self.old_cwd = os.getcwd() + os.chdir(self.dir) + if sys.version >= "2.6": + self.old_base = site.USER_BASE + site.USER_BASE = tempfile.mkdtemp() + self.old_site = site.USER_SITE + site.USER_SITE = tempfile.mkdtemp() + + def tearDown(self): + os.chdir(self.old_cwd) + shutil.rmtree(self.dir) + if sys.version >= "2.6": + shutil.rmtree(site.USER_BASE) + shutil.rmtree(site.USER_SITE) + site.USER_BASE = self.old_base + site.USER_SITE = self.old_site + + def test_install(self): + #XXX: replace with something meaningfull + return + if sys.version < "2.6": + return + dist = Distribution() + dist.script_name = 'setup.py' + cmd = easy_install(dist) + cmd.user = 1 + cmd.args = ['py'] + cmd.ensure_finalized() + cmd.user = 1 + old_stdout = sys.stdout + sys.stdout = StringIO() + try: + cmd.run() + finally: + sys.stdout = old_stdout + + # let's see if we got our egg link at the right place + content = os.listdir(site.USER_SITE) + content.sort() + self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth']) + |