diff options
Diffstat (limited to 'setuptools')
-rwxr-xr-x | setuptools/command/install_scripts.py | 4 | ||||
-rw-r--r-- | setuptools/command/test.py | 6 | ||||
-rw-r--r-- | setuptools/command/upload_docs.py | 6 | ||||
-rwxr-xr-x | setuptools/sandbox.py | 19 | ||||
-rw-r--r-- | setuptools/tests/test_easy_install.py | 10 | ||||
-rw-r--r-- | setuptools/tests/test_sandbox.py | 11 | ||||
-rw-r--r-- | setuptools/tests/test_upload_docs.py | 22 |
7 files changed, 47 insertions, 31 deletions
diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index ac797883..6ce1b993 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -12,8 +12,8 @@ class install_scripts(_install_scripts): self.no_ep = False def run(self): - from setuptools.command.easy_install import (get_script_args, - sys_executable) + from setuptools.command.easy_install import get_script_args + from setuptools.command.easy_install import sys_executable self.run_command("egg_info") if self.distribution.scripts: diff --git a/setuptools/command/test.py b/setuptools/command/test.py index b7aef969..0399f5bf 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -31,7 +31,11 @@ class ScanningLoader(TestLoader): submodule = module.__name__+'.'+file else: continue - tests.append(self.loadTestsFromName(submodule)) + try: + tests.append(self.loadTestsFromName(submodule)) + except Exception, e: + import pdb; pdb.set_trace() + self.loadTestsFromName(submodule) if len(tests)!=1: return self.suiteClass(tests) diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index ea2bad7e..213f7b58 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -16,7 +16,11 @@ import sys from distutils import log from distutils.errors import DistutilsOptionError -from distutils.command.upload import upload + +try: + from distutils.command.upload import upload +except ImportError: + from setuptools.command.upload import upload _IS_PYTHON3 = sys.version > '3' diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 630d5792..13cbe109 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -152,13 +152,18 @@ class AbstractSandbox: ) -_EXCEPTIONS = [os.devnull,] +if hasattr(os, 'devnull'): + _EXCEPTIONS = [os.devnull,] +else: + _EXCEPTIONS = [] -try: - gen_py = os.path.dirname(__import__('win32com.gen_py', fromlist=['__name__']).__file__) - _EXCEPTIONS.append(gen_py) -except ImportError: - pass +if not sys.version < '2.5': + try: + gen_py = os.path.dirname(__import__('win32com.gen_py', + fromlist=['__name__']).__file__) + _EXCEPTIONS.append(gen_py) + except ImportError: + pass class DirectorySandbox(AbstractSandbox): """Restrict operations to a single subdirectory - pseudo-chroot""" @@ -204,7 +209,7 @@ class DirectorySandbox(AbstractSandbox): def _exempted(self, filepath): exception_matches = map(filepath.startswith, self._exceptions) - return any(exception_matches) + return False not in exception_matches def _remap_input(self,operation,path,*args,**kw): """Called for path inputs""" diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index f2655d75..e02798c6 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -122,19 +122,19 @@ class TestEasyInstallTest(unittest.TestCase): class TestPTHFileWriter(unittest.TestCase): def test_add_from_cwd_site_sets_dirty(self): - '''a pth file manager should set dirty + '''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.assertFalse(pth.dirty) + self.assert_(not pth.dirty) pth.add(PRDistribution(os.getcwd())) - self.assertTrue(pth.dirty) + 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.assertFalse(pth.dirty) + self.assert_(not pth.dirty) pth.add(PRDistribution('/test/location/does-not-have-to-exist')) - self.assertFalse(pth.dirty) + self.assert_(not pth.dirty) class TestUserInstallTest(unittest.TestCase): diff --git a/setuptools/tests/test_sandbox.py b/setuptools/tests/test_sandbox.py index 8b9e08e6..1609ee86 100644 --- a/setuptools/tests/test_sandbox.py +++ b/setuptools/tests/test_sandbox.py @@ -30,10 +30,11 @@ class TestSandbox(unittest.TestCase): shutil.rmtree(self.dir) def test_devnull(self): + if sys.version < '2.4': + return sandbox = DirectorySandbox(self.dir) sandbox.run(self._file_writer(os.devnull)) - @staticmethod def _file_writer(path): def do_write(): f = open(path, 'w') @@ -41,6 +42,7 @@ class TestSandbox(unittest.TestCase): f.close() return do_write + _file_writer = staticmethod(_file_writer) if has_win32com(): def test_win32com(self): @@ -53,9 +55,10 @@ class TestSandbox(unittest.TestCase): 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") + 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) diff --git a/setuptools/tests/test_upload_docs.py b/setuptools/tests/test_upload_docs.py index 15db899f..8b2dc892 100644 --- a/setuptools/tests/test_upload_docs.py +++ b/setuptools/tests/test_upload_docs.py @@ -19,24 +19,24 @@ class TestUploadDocsTest(unittest.TestCase): f.close() self.old_cwd = os.getcwd() os.chdir(self.dir) - + self.upload_dir = os.path.join(self.dir, 'build') os.mkdir(self.upload_dir) - + # A test document. f = open(os.path.join(self.upload_dir, 'index.html'), 'w') f.write("Hello world.") f.close() - + # An empty folder. os.mkdir(os.path.join(self.upload_dir, 'empty')) - + if sys.version >= "2.6": self.old_base = site.USER_BASE site.USER_BASE = upload_docs.USER_BASE = tempfile.mkdtemp() self.old_site = site.USER_SITE site.USER_SITE = upload_docs.USER_SITE = tempfile.mkdtemp() - + def tearDown(self): os.chdir(self.old_cwd) shutil.rmtree(self.dir) @@ -49,17 +49,17 @@ class TestUploadDocsTest(unittest.TestCase): def test_create_zipfile(self): # Test to make sure zipfile creation handles common cases. # This explicitly includes a folder containing an empty folder. - + dist = Distribution() - + cmd = upload_docs(dist) cmd.upload_dir = self.upload_dir zip_file = cmd.create_zipfile() - + assert zipfile.is_zipfile(zip_file) - + zip_f = zipfile.ZipFile(zip_file) # woh... - + assert zip_f.namelist() == ['index.html'] - + |