diff options
| author | Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> | 2010-03-16 20:02:39 +0100 |
|---|---|---|
| committer | Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> | 2010-03-16 20:02:39 +0100 |
| commit | 69da648099044a98f094b746c4d0295baf843ea2 (patch) | |
| tree | 2ec89c3ef7aea39affe42c0737057b6d49fef4e8 /setuptools/tests | |
| parent | 0b3d2302b8b209c7bed8bdad6e1a6cff34889779 (diff) | |
| parent | ff3ee4aa6c6800d813162c09a58c6265c4675701 (diff) | |
| download | python-setuptools-git-69da648099044a98f094b746c4d0295baf843ea2.tar.gz | |
merge with upstream
--HG--
branch : distribute
extra : rebase_source : 2ad13527b742644596b32fcd8feac7276b4a477e
Diffstat (limited to 'setuptools/tests')
| -rw-r--r-- | setuptools/tests/test_easy_install.py | 26 | ||||
| -rw-r--r-- | setuptools/tests/test_sandbox.py | 47 |
2 files changed, 66 insertions, 7 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 071ba513..f2655d75 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -95,6 +95,31 @@ 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 @@ -112,7 +137,6 @@ class TestPTHFileWriter(unittest.TestCase): self.assertFalse(pth.dirty) - class TestUserInstallTest(unittest.TestCase): def setUp(self): diff --git a/setuptools/tests/test_sandbox.py b/setuptools/tests/test_sandbox.py index 1b0dc4ea..8b9e08e6 100644 --- a/setuptools/tests/test_sandbox.py +++ b/setuptools/tests/test_sandbox.py @@ -6,7 +6,20 @@ import shutil import unittest import tempfile -from setuptools.sandbox import DirectorySandbox +from setuptools.sandbox import DirectorySandbox, SandboxViolation + +def has_win32com(): + """ + Run this to determine if the local machine has win32com, and if it + does, include additional tests. + """ + if not sys.platform.startswith('win32'): + return False + try: + mod = __import__('win32com') + except ImportError: + return False + return True class TestSandbox(unittest.TestCase): @@ -18,11 +31,33 @@ class TestSandbox(unittest.TestCase): def test_devnull(self): sandbox = DirectorySandbox(self.dir) + sandbox.run(self._file_writer(os.devnull)) - def _write(): - f = open(os.devnull, 'w') + @staticmethod + def _file_writer(path): + def do_write(): + f = open(path, 'w') f.write('xxx') f.close() - - sandbox.run(_write) - + return do_write + + + if has_win32com(): + def test_win32com(self): + """ + win32com should not be prevented from caching COM interfaces + in gen_py. + """ + import win32com + gen_py = win32com.__gen_path__ + target = os.path.join(gen_py, 'test_write') + sandbox = DirectorySandbox(self.dir) + try: + sandbox.run(self._file_writer(target)) + except SandboxViolation: + self.fail("Could not create gen_py file due to SandboxViolation") + finally: + if os.path.exists(target): os.remove(target) + +if __name__ == '__main__': + unittest.main() |
