1
# __init__.py -- The tests for dulwich
2
# Copyright (C) 2007 James Westby <jw+debian@jameswestby.net>
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
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.
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,
20
"""Tests for Dulwich."""
30
if sys.version_info >= (2, 7):
31
# If Python itself provides an exception, use that
33
from unittest import SkipTest, TestCase
35
import unittest2 as unittest
36
from unittest2 import SkipTest, TestCase
39
class BlackboxTestCase(TestCase):
40
"""Blackbox testing."""
42
bin_directory = os.path.abspath(os.path.join(os.path.dirname(__file__),
45
def bin_path(self, name):
46
"""Determine the full path of a binary.
48
:param name: Name of the script
51
return os.path.join(self.bin_directory, name)
53
def run_command(self, name, args):
54
"""Run a Dulwich command.
56
:param name: Name of the command, as it exists in bin/
57
:param args: Arguments to the command
59
env = dict(os.environ)
60
env["PYTHONPATH"] = os.pathsep.join(sys.path)
62
# Since they don't have any extensions, Windows can't recognize
63
# executablility of the Python files in /bin. Even then, we'd have to
64
# expect the user to set up file associations for .py files.
66
# Save us from all that headache and call python with the bin script.
67
argv = [sys.executable, self.bin_path(name)] + args
68
return subprocess.Popen(argv,
69
stdout=subprocess.PIPE,
70
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
74
def self_test_suite():
93
module_names = ['dulwich.tests.test_' + name for name in names]
94
loader = unittest.TestLoader()
95
return loader.loadTestsFromNames(module_names)
98
def tutorial_test_suite():
105
tutorial_files = ["../../docs/tutorial/%s.txt" % name for name in tutorial]
107
test.__dulwich_tempdir = tempfile.mkdtemp()
108
os.chdir(test.__dulwich_tempdir)
110
shutil.rmtree(test.__dulwich_tempdir)
111
return doctest.DocFileSuite(setUp=setup, tearDown=teardown,
115
def nocompat_test_suite():
116
result = unittest.TestSuite()
117
result.addTests(self_test_suite())
118
result.addTests(tutorial_test_suite())
123
result = unittest.TestSuite()
124
result.addTests(self_test_suite())
125
result.addTests(tutorial_test_suite())
126
from dulwich.tests.compat import test_suite as compat_test_suite
127
result.addTests(compat_test_suite())