Commit 6a6a261f authored by Tarek Ziade's avatar Tarek Ziade

make sure all tests passes on all python versions fixes #149

--HG--
branch : distribute
extra : rebase_source : 6288f4fcf65083b9d4ffb0ea8b35af44e699b4d5
parent 3cd50389
...@@ -6,7 +6,7 @@ CHANGES ...@@ -6,7 +6,7 @@ CHANGES
0.6.12 0.6.12
------ ------
* * Issue 149: Fixed various failures on 2.3/2.4
------ ------
0.6.11 0.6.11
......
...@@ -8,6 +8,7 @@ saveopts = setuptools.command.saveopts:saveopts ...@@ -8,6 +8,7 @@ saveopts = setuptools.command.saveopts:saveopts
egg_info = setuptools.command.egg_info:egg_info egg_info = setuptools.command.egg_info:egg_info
register = setuptools.command.register:register register = setuptools.command.register:register
upload_docs = setuptools.command.upload_docs:upload_docs upload_docs = setuptools.command.upload_docs:upload_docs
upload = setuptools.command.upload:upload
install_egg_info = setuptools.command.install_egg_info:install_egg_info install_egg_info = setuptools.command.install_egg_info:install_egg_info
alias = setuptools.command.alias:alias alias = setuptools.command.alias:alias
easy_install = setuptools.command.easy_install:easy_install easy_install = setuptools.command.easy_install:easy_install
...@@ -32,7 +33,7 @@ depends.txt = setuptools.command.egg_info:warn_depends_obsolete ...@@ -32,7 +33,7 @@ depends.txt = setuptools.command.egg_info:warn_depends_obsolete
[console_scripts] [console_scripts]
easy_install = setuptools.command.easy_install:main easy_install = setuptools.command.easy_install:main
easy_install-2.6 = setuptools.command.easy_install:main easy_install-2.3 = setuptools.command.easy_install:main
[setuptools.file_finders] [setuptools.file_finders]
svn_cvs = setuptools.command.sdist:_default_revctrl svn_cvs = setuptools.command.sdist:_default_revctrl
......
...@@ -191,9 +191,10 @@ def _macosx_vers(_cache=[]): ...@@ -191,9 +191,10 @@ def _macosx_vers(_cache=[]):
import plistlib import plistlib
plist = '/System/Library/CoreServices/SystemVersion.plist' plist = '/System/Library/CoreServices/SystemVersion.plist'
if os.path.exists(plist): if os.path.exists(plist):
plist_content = plistlib.readPlist(plist) if hasattr(plistlib, 'readPlist'):
if 'ProductVersion' in plist_content: plist_content = plistlib.readPlist(plist)
version = plist_content['ProductVersion'] if 'ProductVersion' in plist_content:
version = plist_content['ProductVersion']
_cache.append(version.split('.')) _cache.append(version.split('.'))
return _cache[0] return _cache[0]
......
...@@ -12,8 +12,8 @@ class install_scripts(_install_scripts): ...@@ -12,8 +12,8 @@ class install_scripts(_install_scripts):
self.no_ep = False self.no_ep = False
def run(self): def run(self):
from setuptools.command.easy_install import (get_script_args, from setuptools.command.easy_install import get_script_args
sys_executable) from setuptools.command.easy_install import sys_executable
self.run_command("egg_info") self.run_command("egg_info")
if self.distribution.scripts: if self.distribution.scripts:
......
...@@ -31,7 +31,11 @@ class ScanningLoader(TestLoader): ...@@ -31,7 +31,11 @@ class ScanningLoader(TestLoader):
submodule = module.__name__+'.'+file submodule = module.__name__+'.'+file
else: else:
continue 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: if len(tests)!=1:
return self.suiteClass(tests) return self.suiteClass(tests)
......
...@@ -16,7 +16,11 @@ import sys ...@@ -16,7 +16,11 @@ import sys
from distutils import log from distutils import log
from distutils.errors import DistutilsOptionError 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' _IS_PYTHON3 = sys.version > '3'
......
...@@ -152,13 +152,18 @@ class AbstractSandbox: ...@@ -152,13 +152,18 @@ class AbstractSandbox:
) )
_EXCEPTIONS = [os.devnull,] if hasattr(os, 'devnull'):
_EXCEPTIONS = [os.devnull,]
else:
_EXCEPTIONS = []
try: if not sys.version < '2.5':
gen_py = os.path.dirname(__import__('win32com.gen_py', fromlist=['__name__']).__file__) try:
_EXCEPTIONS.append(gen_py) gen_py = os.path.dirname(__import__('win32com.gen_py',
except ImportError: fromlist=['__name__']).__file__)
pass _EXCEPTIONS.append(gen_py)
except ImportError:
pass
class DirectorySandbox(AbstractSandbox): class DirectorySandbox(AbstractSandbox):
"""Restrict operations to a single subdirectory - pseudo-chroot""" """Restrict operations to a single subdirectory - pseudo-chroot"""
...@@ -204,7 +209,7 @@ class DirectorySandbox(AbstractSandbox): ...@@ -204,7 +209,7 @@ class DirectorySandbox(AbstractSandbox):
def _exempted(self, filepath): def _exempted(self, filepath):
exception_matches = map(filepath.startswith, self._exceptions) 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): def _remap_input(self,operation,path,*args,**kw):
"""Called for path inputs""" """Called for path inputs"""
......
...@@ -122,19 +122,19 @@ class TestEasyInstallTest(unittest.TestCase): ...@@ -122,19 +122,19 @@ class TestEasyInstallTest(unittest.TestCase):
class TestPTHFileWriter(unittest.TestCase): class TestPTHFileWriter(unittest.TestCase):
def test_add_from_cwd_site_sets_dirty(self): 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 if a distribution is in site but also the cwd
''' '''
pth = PthDistributions('does-not_exist', [os.getcwd()]) pth = PthDistributions('does-not_exist', [os.getcwd()])
self.assertFalse(pth.dirty) self.assert_(not pth.dirty)
pth.add(PRDistribution(os.getcwd())) pth.add(PRDistribution(os.getcwd()))
self.assertTrue(pth.dirty) self.assert_(pth.dirty)
def test_add_from_site_is_ignored(self): def test_add_from_site_is_ignored(self):
pth = PthDistributions('does-not_exist', ['/test/location/does-not-have-to-exist']) 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')) pth.add(PRDistribution('/test/location/does-not-have-to-exist'))
self.assertFalse(pth.dirty) self.assert_(not pth.dirty)
class TestUserInstallTest(unittest.TestCase): class TestUserInstallTest(unittest.TestCase):
......
...@@ -30,10 +30,11 @@ class TestSandbox(unittest.TestCase): ...@@ -30,10 +30,11 @@ class TestSandbox(unittest.TestCase):
shutil.rmtree(self.dir) shutil.rmtree(self.dir)
def test_devnull(self): def test_devnull(self):
if sys.version < '2.4':
return
sandbox = DirectorySandbox(self.dir) sandbox = DirectorySandbox(self.dir)
sandbox.run(self._file_writer(os.devnull)) sandbox.run(self._file_writer(os.devnull))
@staticmethod
def _file_writer(path): def _file_writer(path):
def do_write(): def do_write():
f = open(path, 'w') f = open(path, 'w')
...@@ -41,6 +42,7 @@ class TestSandbox(unittest.TestCase): ...@@ -41,6 +42,7 @@ class TestSandbox(unittest.TestCase):
f.close() f.close()
return do_write return do_write
_file_writer = staticmethod(_file_writer)
if has_win32com(): if has_win32com():
def test_win32com(self): def test_win32com(self):
...@@ -53,9 +55,10 @@ class TestSandbox(unittest.TestCase): ...@@ -53,9 +55,10 @@ class TestSandbox(unittest.TestCase):
target = os.path.join(gen_py, 'test_write') target = os.path.join(gen_py, 'test_write')
sandbox = DirectorySandbox(self.dir) sandbox = DirectorySandbox(self.dir)
try: try:
sandbox.run(self._file_writer(target)) try:
except SandboxViolation: sandbox.run(self._file_writer(target))
self.fail("Could not create gen_py file due to SandboxViolation") except SandboxViolation:
self.fail("Could not create gen_py file due to SandboxViolation")
finally: finally:
if os.path.exists(target): os.remove(target) if os.path.exists(target): os.remove(target)
......
...@@ -19,24 +19,24 @@ class TestUploadDocsTest(unittest.TestCase): ...@@ -19,24 +19,24 @@ class TestUploadDocsTest(unittest.TestCase):
f.close() f.close()
self.old_cwd = os.getcwd() self.old_cwd = os.getcwd()
os.chdir(self.dir) os.chdir(self.dir)
self.upload_dir = os.path.join(self.dir, 'build') self.upload_dir = os.path.join(self.dir, 'build')
os.mkdir(self.upload_dir) os.mkdir(self.upload_dir)
# A test document. # A test document.
f = open(os.path.join(self.upload_dir, 'index.html'), 'w') f = open(os.path.join(self.upload_dir, 'index.html'), 'w')
f.write("Hello world.") f.write("Hello world.")
f.close() f.close()
# An empty folder. # An empty folder.
os.mkdir(os.path.join(self.upload_dir, 'empty')) os.mkdir(os.path.join(self.upload_dir, 'empty'))
if sys.version >= "2.6": if sys.version >= "2.6":
self.old_base = site.USER_BASE self.old_base = site.USER_BASE
site.USER_BASE = upload_docs.USER_BASE = tempfile.mkdtemp() site.USER_BASE = upload_docs.USER_BASE = tempfile.mkdtemp()
self.old_site = site.USER_SITE self.old_site = site.USER_SITE
site.USER_SITE = upload_docs.USER_SITE = tempfile.mkdtemp() site.USER_SITE = upload_docs.USER_SITE = tempfile.mkdtemp()
def tearDown(self): def tearDown(self):
os.chdir(self.old_cwd) os.chdir(self.old_cwd)
shutil.rmtree(self.dir) shutil.rmtree(self.dir)
...@@ -49,17 +49,17 @@ class TestUploadDocsTest(unittest.TestCase): ...@@ -49,17 +49,17 @@ class TestUploadDocsTest(unittest.TestCase):
def test_create_zipfile(self): def test_create_zipfile(self):
# Test to make sure zipfile creation handles common cases. # Test to make sure zipfile creation handles common cases.
# This explicitly includes a folder containing an empty folder. # This explicitly includes a folder containing an empty folder.
dist = Distribution() dist = Distribution()
cmd = upload_docs(dist) cmd = upload_docs(dist)
cmd.upload_dir = self.upload_dir cmd.upload_dir = self.upload_dir
zip_file = cmd.create_zipfile() zip_file = cmd.create_zipfile()
assert zipfile.is_zipfile(zip_file) assert zipfile.is_zipfile(zip_file)
zip_f = zipfile.ZipFile(zip_file) # woh... zip_f = zipfile.ZipFile(zip_file) # woh...
assert zip_f.namelist() == ['index.html'] assert zip_f.namelist() == ['index.html']
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