Browse Source

Use TestTools' TestCase so TestSkipped gets picked up correctly.

Jelmer Vernooij 15 years ago
parent
commit
3ef09128a8

+ 3 - 0
NEWS

@@ -6,6 +6,9 @@
 
   * Use correct path separators for named repo files. (Dave Borowitz)
 
+  * python > 2.7 and testtools-based test runners will now also pick up skipped
+    tests correctly. (Jelmer Vernooij)
+
  FEATURES
 
   * Move named file initilization to BaseRepo. (Dave Borowitz)

+ 4 - 1
dulwich/tests/__init__.py

@@ -21,7 +21,10 @@
 
 import unittest
 
-from unittest import TestCase
+try:
+    from testtools.testcase import TestCase
+except ImportError:
+    from unittest import TestCase
 
 try:
     # If Python itself provides an exception, use that

+ 1 - 0
dulwich/tests/test_client.py

@@ -30,6 +30,7 @@ from dulwich.tests import (
 class GitClientTests(TestCase):
 
     def setUp(self):
+        super(GitClientTests, self).setUp()
         self.rout = StringIO()
         self.rin = StringIO()
         self.client = GitClient(lambda x: True, self.rin.read,

+ 4 - 0
dulwich/tests/test_file.py

@@ -32,6 +32,7 @@ from dulwich.tests import (
 class FancyRenameTests(TestCase):
 
     def setUp(self):
+        super(FancyRenameTests, self).setUp()
         self._tempdir = tempfile.mkdtemp()
         self.foo = self.path('foo')
         self.bar = self.path('bar')
@@ -39,6 +40,7 @@ class FancyRenameTests(TestCase):
 
     def tearDown(self):
         shutil.rmtree(self._tempdir)
+        super(FancyRenameTests, self).tearDown()
 
     def path(self, filename):
         return os.path.join(self._tempdir, filename)
@@ -87,6 +89,7 @@ class FancyRenameTests(TestCase):
 class GitFileTests(TestCase):
 
     def setUp(self):
+        super(GitFileTests, self).setUp()
         self._tempdir = tempfile.mkdtemp()
         f = open(self.path('foo'), 'wb')
         f.write('foo contents')
@@ -94,6 +97,7 @@ class GitFileTests(TestCase):
 
     def tearDown(self):
         shutil.rmtree(self._tempdir)
+        super(GitFileTests, self).tearDown()
 
     def path(self, filename):
         return os.path.join(self._tempdir, filename)

+ 3 - 0
dulwich/tests/test_pack.py

@@ -60,10 +60,12 @@ class PackTests(TestCase):
     """Base class for testing packs"""
 
     def setUp(self):
+        super(PackTests, self).setUp()
         self.tempdir = tempfile.mkdtemp()
 
     def tearDown(self):
         shutil.rmtree(self.tempdir)
+        super(PackTests, self).tearDown()
 
     datadir = os.path.join(os.path.dirname(__file__), 'data/packs')
 
@@ -361,6 +363,7 @@ class ReadZlibTests(TestCase):
     extra = 'nextobject'
 
     def setUp(self):
+        super(ReadZlibTests, self).setUp()
         self.read = StringIO(self.comp + self.extra).read
 
     def test_decompress_size(self):

+ 7 - 0
dulwich/tests/test_repository.py

@@ -86,11 +86,13 @@ class CreateRepositoryTests(TestCase):
 class RepositoryTests(TestCase):
 
     def setUp(self):
+        super(RepositoryTests, self).setUp()
         self._repo = None
 
     def tearDown(self):
         if self._repo is not None:
             tear_down_repo(self._repo)
+        super(RepositoryTests, self).tearDown()
 
     def test_simple_props(self):
         r = self._repo = open_repo('a.git')
@@ -338,6 +340,7 @@ class BuildRepoTests(TestCase):
     """
 
     def setUp(self):
+        super(BuildRepoTests, self).setUp()
         repo_dir = os.path.join(tempfile.mkdtemp(), 'test')
         os.makedirs(repo_dir)
         r = self._repo = Repo.init(repo_dir)
@@ -361,6 +364,7 @@ class BuildRepoTests(TestCase):
 
     def tearDown(self):
         tear_down_repo(self._repo)
+        super(BuildRepoTests, self).tearDown()
 
     def test_build_repo(self):
         r = self._repo
@@ -624,17 +628,20 @@ class RefsContainerTests(object):
 class DictRefsContainerTests(RefsContainerTests, TestCase):
 
     def setUp(self):
+        TestCase.setUp(self)
         self._refs = DictRefsContainer(dict(_TEST_REFS))
 
 
 class DiskRefsContainerTests(RefsContainerTests, TestCase):
 
     def setUp(self):
+        TestCase.setUp(self)
         self._repo = open_repo('refs.git')
         self._refs = self._repo.refs
 
     def tearDown(self):
         tear_down_repo(self._repo)
+        TestCase.tearDown(self)
 
     def test_get_packed_refs(self):
         self.assertEqual({

+ 4 - 0
dulwich/tests/test_server.py

@@ -79,6 +79,7 @@ class TestProto(object):
 class HandlerTestCase(TestCase):
 
     def setUp(self):
+        super(HandlerTestCase, self).setUp()
         self._handler = Handler(Backend(), None)
         self._handler.capabilities = lambda: ('cap1', 'cap2', 'cap3')
         self._handler.required_capabilities = lambda: ('cap2',)
@@ -122,6 +123,7 @@ class HandlerTestCase(TestCase):
 class UploadPackHandlerTestCase(TestCase):
 
     def setUp(self):
+        super(UploadPackHandlerTestCase, self).setUp()
         self._backend = DictBackend({"/": BackendRepo()})
         self._handler = UploadPackHandler(self._backend,
                 ["/", "host=lolcathost"], None, None)
@@ -213,6 +215,7 @@ class TestUploadPackHandler(Handler):
 class ProtocolGraphWalkerTestCase(TestCase):
 
     def setUp(self):
+        super(ProtocolGraphWalkerTestCase, self).setUp()
         # Create the following commit tree:
         #   3---5
         #  /
@@ -357,6 +360,7 @@ class AckGraphWalkerImplTestCase(TestCase):
     """Base setup and asserts for AckGraphWalker tests."""
 
     def setUp(self):
+        super(AckGraphWalkerImplTestCase, self).setUp()
         self._walker = TestProtocolGraphWalker()
         self._walker.lines = [
           ('have', TWO),

+ 3 - 0
dulwich/tests/test_web.py

@@ -44,6 +44,7 @@ class WebTestCase(TestCase):
     """Base TestCase that sets up some useful instance vars."""
 
     def setUp(self):
+        super(WebTestCase, self).setUp()
         self._environ = {}
         self._req = HTTPGitRequest(self._environ, self._start_response,
                                    handlers=self._handlers())
@@ -284,7 +285,9 @@ class HTTPGitRequestTestCase(WebTestCase):
 
 
 class HTTPGitApplicationTestCase(TestCase):
+
     def setUp(self):
+        super(HTTPGitApplicationTestCase, self).setUp()
         self._app = HTTPGitApplication('backend')
 
     def test_call(self):