~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Aaron Bentley
  • Date: 2005-09-10 23:46:35 UTC
  • mto: (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: aaron.bentley@utoronto.ca-20050910234635-2586547c19f8c4cc
Updated name to farthest_nodes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License version 2 as published by
5
 
# the Free Software Foundation.
6
 
#
7
 
# This program is distributed in the hope that it will be useful,
8
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
# GNU General Public License for more details.
11
 
#
12
 
# You should have received a copy of the GNU General Public License
13
 
# along with this program; if not, write to the Free Software
14
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 
 
16
 
"""Tests for the test framework
17
 
"""
18
 
 
19
 
import os
20
 
import sys
21
 
import unittest
22
 
 
23
 
from bzrlib.tests import (
24
 
                          _load_module_by_name,
25
 
                          TestCase,
26
 
                          TestCaseInTempDir,
27
 
                          TestSkipped,
28
 
                          TextTestRunner,
29
 
                          )
30
 
 
31
 
 
32
 
class SelftestTests(TestCase):
33
 
 
34
 
    def test_import_tests(self):
35
 
        mod = _load_module_by_name('bzrlib.tests.test_selftest')
36
 
        self.assertEqual(mod.SelftestTests, SelftestTests)
37
 
 
38
 
    def test_import_test_failure(self):
39
 
        self.assertRaises(ImportError,
40
 
                          _load_module_by_name,
41
 
                          'bzrlib.no-name-yet')
42
 
 
43
 
 
44
 
class MetaTestLog(TestCase):
45
 
 
46
 
    def test_logging(self):
47
 
        """Test logs are captured when a test fails."""
48
 
        self.log('a test message')
49
 
        self._log_file.flush()
50
 
        self.assertContainsRe(self._get_log(), 'a test message\n')
51
 
 
52
 
 
53
 
class TestTreeShape(TestCaseInTempDir):
54
 
 
55
 
    def test_unicode_paths(self):
56
 
        filename = u'hell\u00d8'
57
 
        try:
58
 
            self.build_tree_contents([(filename, 'contents of hello')])
59
 
        except UnicodeEncodeError:
60
 
            raise TestSkipped("can't build unicode working tree in "
61
 
                "filesystem encoding %s" % sys.getfilesystemencoding())
62
 
        self.failUnlessExists(filename)
63
 
 
64
 
 
65
 
class TestSkippedTest(TestCase):
66
 
    """Try running a test which is skipped, make sure it's reported properly."""
67
 
    def test_skipped_test(self):
68
 
        # must be hidden in here so it's not run as a real test
69
 
        def skipping_test():
70
 
            raise TestSkipped('test intentionally skipped')
71
 
        runner = TextTestRunner(stream=self._log_file)
72
 
        test = unittest.FunctionTestCase(skipping_test)
73
 
        result = runner.run(test)
74
 
        self.assertTrue(result.wasSuccessful())