diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-12-15 22:38:35 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-12-15 22:38:35 -0500 |
commit | 2ae2dcf1a9b7e0e3a36b10fbc2301a8d0555f701 (patch) | |
tree | cf9d89635ab72c7b443b97c05e19d042477de85c | |
parent | 6839dc1f937c72393e5e9202030962454e0c3b20 (diff) | |
parent | f9887552d25548a09d1d1f08996543f7ba457b85 (diff) | |
download | python-setuptools-bitbucket-2ae2dcf1a9b7e0e3a36b10fbc2301a8d0555f701.tar.gz |
Merge
-rw-r--r-- | setuptools/tests/environment.py | 7 | ||||
-rw-r--r-- | setuptools/tests/test_egg_info.py | 21 | ||||
-rw-r--r-- | setuptools/tests/test_sdist.py | 7 | ||||
-rw-r--r-- | setuptools/tests/test_svn.py | 31 |
4 files changed, 53 insertions, 13 deletions
diff --git a/setuptools/tests/environment.py b/setuptools/tests/environment.py index bd2c53d2..476d280a 100644 --- a/setuptools/tests/environment.py +++ b/setuptools/tests/environment.py @@ -78,6 +78,9 @@ class ZippedEnvironment(unittest.TestCase): old_cwd = None def setUp(self): + if self.datafile is None or self.dataname is None: + return + if not os.path.isfile(self.datafile): self.old_cwd = None return @@ -98,6 +101,10 @@ class ZippedEnvironment(unittest.TestCase): os.chdir(os.path.join(self.temp_dir, self.dataname)) def tearDown(self): + #Assume setUp was never completed + if self.dataname is None or self.datafile is None: + return + try: if self.old_cwd: os.chdir(self.old_cwd) diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 28682dfd..27854366 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -8,8 +8,9 @@ import unittest import pkg_resources import warnings from setuptools.command import egg_info -from setuptools.tests import environment from setuptools import svn_utils +from setuptools.tests import environment, test_svn +from setuptools.tests.py26compat import skipIf ENTRIES_V10 = pkg_resources.resource_string(__name__, 'entries-v10') "An entries file generated with svn 1.6.17 against the legacy Setuptools repo" @@ -33,7 +34,8 @@ class TestEggInfo(unittest.TestCase): entries_f = open(fn, 'wb') entries_f.write(entries) entries_f.close() - + + @skipIf(not test_svn._svn_check, "No SVN to text, in the first place") def test_version_10_format(self): """ """ @@ -60,11 +62,9 @@ class TestEggInfo(unittest.TestCase): if env.lower() == 'path': path_variable = env - if path_variable is None: - self.skipTest('Cannot figure out how to modify path') - - old_path = os.environ[path_variable] - os.environ[path_variable] = '' + if path_variable: + old_path = os.environ[path_variable] + os.environ[path_variable] = '' #catch_warnings not available until py26 warning_filters = warnings.filters warnings.filters = warning_filters[:] @@ -76,7 +76,8 @@ class TestEggInfo(unittest.TestCase): #restore the warning filters warnings.filters = warning_filters #restore the os path - os.environ[path_variable] = old_path + if path_variable: + os.environ[path_variable] = old_path self.assertEqual(rev, '89000') @@ -99,6 +100,9 @@ class TestSvnDummy(environment.ZippedEnvironment): def setUp(self): version = svn_utils.SvnInfo.get_svn_version() + if not version: # None or Empty + return None + self.base_version = tuple([int(x) for x in version.split('.')][:2]) if not self.base_version: @@ -114,6 +118,7 @@ class TestSvnDummy(environment.ZippedEnvironment): 'svn_data', self.dataname + ".zip") super(TestSvnDummy, self).setUp() + @skipIf(not test_svn._svn_check, "No SVN to text, in the first place") def test_sources(self): code, data = environment.run_setup_py(["sdist"], pypath=self.old_cwd, diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index b42dcc57..71d10757 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -9,7 +9,8 @@ import tempfile import unittest import unicodedata import re -from setuptools.tests import environment +from setuptools.tests import environment, test_svn +from setuptools.tests.py26compat import skipIf from setuptools.compat import StringIO, unicode from setuptools.tests.py26compat import skipIf @@ -473,6 +474,9 @@ class TestSvn(environment.ZippedEnvironment): def setUp(self): version = svn_utils.SvnInfo.get_svn_version() + if not version: # None or Empty + return + self.base_version = tuple([int(x) for x in version.split('.')][:2]) if not self.base_version: @@ -488,6 +492,7 @@ class TestSvn(environment.ZippedEnvironment): 'svn_data', self.dataname + ".zip") super(TestSvn, self).setUp() + @skipIf(not test_svn._svn_check, "No SVN to text, in the first place") def test_walksvn(self): if self.base_version >= (1, 6): folder2 = 'third party2' diff --git a/setuptools/tests/test_svn.py b/setuptools/tests/test_svn.py index 5418b9a4..afee32b6 100644 --- a/setuptools/tests/test_svn.py +++ b/setuptools/tests/test_svn.py @@ -3,12 +3,25 @@ import os +import sys import unittest import codecs +import subprocess from setuptools.tests import environment from setuptools.compat import unicode, unichr from setuptools import svn_utils +from setuptools.tests.py26compat import skipIf + + +def _do_svn_check(): + try: + subprocess.check_call(["svn", "--version"], + shell=(sys.platform == 'win32')) + return True + except (OSError, subprocess.CalledProcessError): + return False +_svn_check = _do_svn_check() class TestSvnVersion(unittest.TestCase): @@ -20,7 +33,10 @@ class TestSvnVersion(unittest.TestCase): path_variable = env if path_variable is None: - self.skipTest('Cannot figure out how to modify path') + try: + self.skipTest('Cannot figure out how to modify path') + except AttributeError: # PY26 doesn't have this + return old_path = os.environ[path_variable] os.environ[path_variable] = '' @@ -30,6 +46,7 @@ class TestSvnVersion(unittest.TestCase): finally: os.environ[path_variable] = old_path + @skipIf(not _svn_check, "No SVN to text, in the first place") def test_svn_should_exist(self): version = svn_utils.SvnInfo.get_svn_version() self.assertNotEqual(version, '') @@ -169,11 +186,14 @@ class TestSvn(environment.ZippedEnvironment): def setUp(self): version = svn_utils.SvnInfo.get_svn_version() + if not version: # empty or null + self.dataname = None + self.datafile = None + return + self.base_version = tuple([int(x) for x in version.split('.')[:2]]) - if not self.base_version: - raise ValueError('No SVN tools installed') - elif self.base_version < (1,3): + if self.base_version < (1,3): raise ValueError('Insufficient SVN Version %s' % version) elif self.base_version >= (1,9): #trying the latest version @@ -184,10 +204,12 @@ class TestSvn(environment.ZippedEnvironment): 'svn_data', self.dataname + ".zip") super(TestSvn, self).setUp() + @skipIf(not _svn_check, "No SVN to text, in the first place") def test_revision(self): rev = svn_utils.SvnInfo.load('.').get_revision() self.assertEqual(rev, 6) + @skipIf(not _svn_check, "No SVN to text, in the first place") def test_entries(self): expected = set([ (os.path.join('a file'), 'file'), @@ -200,6 +222,7 @@ class TestSvn(environment.ZippedEnvironment): info = svn_utils.SvnInfo.load('.') self.assertEqual(set(x for x in info.entries), expected) + @skipIf(not _svn_check, "No SVN to text, in the first place") def test_externals(self): if self.base_version >= (1,6): folder2 = 'third party2' |