Commit 9eb9ea1b authored by Jason R. Coombs's avatar Jason R. Coombs

Merge

parents 074f677e da064e60
...@@ -78,6 +78,9 @@ class ZippedEnvironment(unittest.TestCase): ...@@ -78,6 +78,9 @@ class ZippedEnvironment(unittest.TestCase):
old_cwd = None old_cwd = None
def setUp(self): def setUp(self):
if self.datafile is None or self.dataname is None:
return
if not os.path.isfile(self.datafile): if not os.path.isfile(self.datafile):
self.old_cwd = None self.old_cwd = None
return return
...@@ -98,6 +101,10 @@ class ZippedEnvironment(unittest.TestCase): ...@@ -98,6 +101,10 @@ class ZippedEnvironment(unittest.TestCase):
os.chdir(os.path.join(self.temp_dir, self.dataname)) os.chdir(os.path.join(self.temp_dir, self.dataname))
def tearDown(self): def tearDown(self):
#Assume setUp was never completed
if self.dataname is None or self.datafile is None:
return
try: try:
if self.old_cwd: if self.old_cwd:
os.chdir(self.old_cwd) os.chdir(self.old_cwd)
......
...@@ -8,8 +8,9 @@ import unittest ...@@ -8,8 +8,9 @@ import unittest
import pkg_resources import pkg_resources
import warnings import warnings
from setuptools.command import egg_info from setuptools.command import egg_info
from setuptools.tests import environment
from setuptools import svn_utils 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') ENTRIES_V10 = pkg_resources.resource_string(__name__, 'entries-v10')
"An entries file generated with svn 1.6.17 against the legacy Setuptools repo" "An entries file generated with svn 1.6.17 against the legacy Setuptools repo"
...@@ -33,7 +34,8 @@ class TestEggInfo(unittest.TestCase): ...@@ -33,7 +34,8 @@ class TestEggInfo(unittest.TestCase):
entries_f = open(fn, 'wb') entries_f = open(fn, 'wb')
entries_f.write(entries) entries_f.write(entries)
entries_f.close() entries_f.close()
@skipIf(not test_svn._svn_check, "No SVN to text, in the first place")
def test_version_10_format(self): def test_version_10_format(self):
""" """
""" """
...@@ -60,11 +62,9 @@ class TestEggInfo(unittest.TestCase): ...@@ -60,11 +62,9 @@ class TestEggInfo(unittest.TestCase):
if env.lower() == 'path': if env.lower() == 'path':
path_variable = env path_variable = env
if path_variable is None: if path_variable:
self.skipTest('Cannot figure out how to modify path') old_path = os.environ[path_variable]
os.environ[path_variable] = ''
old_path = os.environ[path_variable]
os.environ[path_variable] = ''
#catch_warnings not available until py26 #catch_warnings not available until py26
warning_filters = warnings.filters warning_filters = warnings.filters
warnings.filters = warning_filters[:] warnings.filters = warning_filters[:]
...@@ -76,7 +76,8 @@ class TestEggInfo(unittest.TestCase): ...@@ -76,7 +76,8 @@ class TestEggInfo(unittest.TestCase):
#restore the warning filters #restore the warning filters
warnings.filters = warning_filters warnings.filters = warning_filters
#restore the os path #restore the os path
os.environ[path_variable] = old_path if path_variable:
os.environ[path_variable] = old_path
self.assertEqual(rev, '89000') self.assertEqual(rev, '89000')
...@@ -99,6 +100,9 @@ class TestSvnDummy(environment.ZippedEnvironment): ...@@ -99,6 +100,9 @@ class TestSvnDummy(environment.ZippedEnvironment):
def setUp(self): def setUp(self):
version = svn_utils.SvnInfo.get_svn_version() 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]) self.base_version = tuple([int(x) for x in version.split('.')][:2])
if not self.base_version: if not self.base_version:
...@@ -114,6 +118,7 @@ class TestSvnDummy(environment.ZippedEnvironment): ...@@ -114,6 +118,7 @@ class TestSvnDummy(environment.ZippedEnvironment):
'svn_data', self.dataname + ".zip") 'svn_data', self.dataname + ".zip")
super(TestSvnDummy, self).setUp() super(TestSvnDummy, self).setUp()
@skipIf(not test_svn._svn_check, "No SVN to text, in the first place")
def test_sources(self): def test_sources(self):
code, data = environment.run_setup_py(["sdist"], code, data = environment.run_setup_py(["sdist"],
pypath=self.old_cwd, pypath=self.old_cwd,
......
...@@ -9,7 +9,8 @@ import tempfile ...@@ -9,7 +9,8 @@ import tempfile
import unittest import unittest
import unicodedata import unicodedata
import re 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.compat import StringIO, unicode
from setuptools.tests.py26compat import skipIf from setuptools.tests.py26compat import skipIf
...@@ -473,6 +474,9 @@ class TestSvn(environment.ZippedEnvironment): ...@@ -473,6 +474,9 @@ class TestSvn(environment.ZippedEnvironment):
def setUp(self): def setUp(self):
version = svn_utils.SvnInfo.get_svn_version() 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]) self.base_version = tuple([int(x) for x in version.split('.')][:2])
if not self.base_version: if not self.base_version:
...@@ -488,6 +492,7 @@ class TestSvn(environment.ZippedEnvironment): ...@@ -488,6 +492,7 @@ class TestSvn(environment.ZippedEnvironment):
'svn_data', self.dataname + ".zip") 'svn_data', self.dataname + ".zip")
super(TestSvn, self).setUp() super(TestSvn, self).setUp()
@skipIf(not test_svn._svn_check, "No SVN to text, in the first place")
def test_walksvn(self): def test_walksvn(self):
if self.base_version >= (1, 6): if self.base_version >= (1, 6):
folder2 = 'third party2' folder2 = 'third party2'
......
...@@ -3,12 +3,25 @@ ...@@ -3,12 +3,25 @@
import os import os
import sys
import unittest import unittest
import codecs import codecs
import subprocess
from setuptools.tests import environment from setuptools.tests import environment
from setuptools.compat import unicode, unichr from setuptools.compat import unicode, unichr
from setuptools import svn_utils 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): class TestSvnVersion(unittest.TestCase):
...@@ -20,7 +33,10 @@ class TestSvnVersion(unittest.TestCase): ...@@ -20,7 +33,10 @@ class TestSvnVersion(unittest.TestCase):
path_variable = env path_variable = env
if path_variable is None: 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] old_path = os.environ[path_variable]
os.environ[path_variable] = '' os.environ[path_variable] = ''
...@@ -30,6 +46,7 @@ class TestSvnVersion(unittest.TestCase): ...@@ -30,6 +46,7 @@ class TestSvnVersion(unittest.TestCase):
finally: finally:
os.environ[path_variable] = old_path os.environ[path_variable] = old_path
@skipIf(not _svn_check, "No SVN to text, in the first place")
def test_svn_should_exist(self): def test_svn_should_exist(self):
version = svn_utils.SvnInfo.get_svn_version() version = svn_utils.SvnInfo.get_svn_version()
self.assertNotEqual(version, '') self.assertNotEqual(version, '')
...@@ -169,11 +186,14 @@ class TestSvn(environment.ZippedEnvironment): ...@@ -169,11 +186,14 @@ class TestSvn(environment.ZippedEnvironment):
def setUp(self): def setUp(self):
version = svn_utils.SvnInfo.get_svn_version() 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]]) self.base_version = tuple([int(x) for x in version.split('.')[:2]])
if not self.base_version: if self.base_version < (1,3):
raise ValueError('No SVN tools installed')
elif self.base_version < (1,3):
raise ValueError('Insufficient SVN Version %s' % version) raise ValueError('Insufficient SVN Version %s' % version)
elif self.base_version >= (1,9): elif self.base_version >= (1,9):
#trying the latest version #trying the latest version
...@@ -184,10 +204,12 @@ class TestSvn(environment.ZippedEnvironment): ...@@ -184,10 +204,12 @@ class TestSvn(environment.ZippedEnvironment):
'svn_data', self.dataname + ".zip") 'svn_data', self.dataname + ".zip")
super(TestSvn, self).setUp() super(TestSvn, self).setUp()
@skipIf(not _svn_check, "No SVN to text, in the first place")
def test_revision(self): def test_revision(self):
rev = svn_utils.SvnInfo.load('.').get_revision() rev = svn_utils.SvnInfo.load('.').get_revision()
self.assertEqual(rev, 6) self.assertEqual(rev, 6)
@skipIf(not _svn_check, "No SVN to text, in the first place")
def test_entries(self): def test_entries(self):
expected = set([ expected = set([
(os.path.join('a file'), 'file'), (os.path.join('a file'), 'file'),
...@@ -200,6 +222,7 @@ class TestSvn(environment.ZippedEnvironment): ...@@ -200,6 +222,7 @@ class TestSvn(environment.ZippedEnvironment):
info = svn_utils.SvnInfo.load('.') info = svn_utils.SvnInfo.load('.')
self.assertEqual(set(x for x in info.entries), expected) 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): def test_externals(self):
if self.base_version >= (1,6): if self.base_version >= (1,6):
folder2 = 'third party2' folder2 = 'third party2'
......
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