943a929dd1c1476488d0a331248a40f02c9f5691
[jelmer/dulwich-libgit2.git] / dulwich / tests / __init__.py
1 # __init__.py -- The tests for dulwich
2 # Copyright (C) 2007 James Westby <jw+debian@jameswestby.net>
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; version 2
7 # of the License or (at your option) any later version of
8 # the License.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 # MA  02110-1301, USA.
19
20 """Tests for Dulwich."""
21
22 import unittest
23
24 try:
25     # If Python itself provides an exception, use that
26     from unittest import SkipTest as TestSkipped
27 except ImportError:
28     # Check if the nose exception can be used
29     try:
30         import nose
31     except ImportError:
32         try:
33             import testtools.testcase
34         except ImportError:
35             class TestSkipped(Exception):
36                 def __init__(self, msg):
37                     self.msg = msg
38         else:
39             TestSkipped = testtools.testcase.TestCase.skipException
40     else:
41         TestSkipped = nose.SkipTest
42         try:
43             import testtools.testcase
44         except ImportError:
45             pass
46         else:
47             # Make testtools use the same exception class as nose
48             testtools.testcase.TestCase.skipException = TestSkipped
49
50
51 def test_suite():
52     names = [
53         'client',
54         'fastexport',
55         'file',
56         'index',
57         'lru_cache',
58         'objects',
59         'object_store',
60         'pack',
61         'patch',
62         'protocol',
63         'repository',
64         'server',
65         'web',
66         ]
67     module_names = ['dulwich.tests.test_' + name for name in names]
68     result = unittest.TestSuite()
69     loader = unittest.TestLoader()
70     suite = loader.loadTestsFromNames(module_names)
71     result.addTests(suite)
72     return result