Commit da064e60 authored by Jason R. Coombs's avatar Jason R. Coombs

Merged in philip_thiem/setuptools (pull request #27)

Fixed tests for skipping when svn not present.
parents 02a2d475 8bbdac7d
......@@ -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)
......
......@@ -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,
......
......@@ -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'
......
......@@ -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'
......
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