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
0.6.12
------
*
* Issue 149: Fixed various failures on 2.3/2.4
------
0.6.11
......
......@@ -8,6 +8,7 @@ saveopts = setuptools.command.saveopts:saveopts
egg_info = setuptools.command.egg_info:egg_info
register = setuptools.command.register:register
upload_docs = setuptools.command.upload_docs:upload_docs
upload = setuptools.command.upload:upload
install_egg_info = setuptools.command.install_egg_info:install_egg_info
alias = setuptools.command.alias:alias
easy_install = setuptools.command.easy_install:easy_install
......@@ -32,7 +33,7 @@ depends.txt = setuptools.command.egg_info:warn_depends_obsolete
[console_scripts]
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]
svn_cvs = setuptools.command.sdist:_default_revctrl
......
......@@ -191,9 +191,10 @@ def _macosx_vers(_cache=[]):
import plistlib
plist = '/System/Library/CoreServices/SystemVersion.plist'
if os.path.exists(plist):
plist_content = plistlib.readPlist(plist)
if 'ProductVersion' in plist_content:
version = plist_content['ProductVersion']
if hasattr(plistlib, 'readPlist'):
plist_content = plistlib.readPlist(plist)
if 'ProductVersion' in plist_content:
version = plist_content['ProductVersion']
_cache.append(version.split('.'))
return _cache[0]
......
......@@ -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:
......
......@@ -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)
......
......@@ -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'
......
......@@ -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"""
......
......@@ -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):
......
......@@ -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)
......
......@@ -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']
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