__init__.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. """Tests for Dulwich."""
  20. import unittest
  21. try:
  22. from testtools.testcase import TestCase
  23. except ImportError:
  24. from unittest import TestCase
  25. try:
  26. # If Python itself provides an exception, use that
  27. from unittest import SkipTest as TestSkipped
  28. except ImportError:
  29. # Check if the nose exception can be used
  30. try:
  31. import nose
  32. except ImportError:
  33. try:
  34. import testtools.testcase
  35. except ImportError:
  36. class TestSkipped(Exception):
  37. def __init__(self, msg):
  38. self.msg = msg
  39. else:
  40. TestSkipped = testtools.testcase.TestCase.skipException
  41. else:
  42. TestSkipped = nose.SkipTest
  43. try:
  44. import testtools.testcase
  45. except ImportError:
  46. pass
  47. else:
  48. # Make testtools use the same exception class as nose
  49. testtools.testcase.TestCase.skipException = TestSkipped
  50. def test_suite():
  51. names = [
  52. 'client',
  53. 'fastexport',
  54. 'file',
  55. 'index',
  56. 'lru_cache',
  57. 'objects',
  58. 'object_store',
  59. 'pack',
  60. 'patch',
  61. 'protocol',
  62. 'repository',
  63. 'server',
  64. 'web',
  65. ]
  66. module_names = ['dulwich.tests.test_' + name for name in names]
  67. result = unittest.TestSuite()
  68. loader = unittest.TestLoader()
  69. suite = loader.loadTestsFromNames(module_names)
  70. result.addTests(suite)
  71. return result