~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

Merge from mbp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import os
20
20
import sys
 
21
import unittest
21
22
 
22
 
from bzrlib.tests import TestCase, _load_module_by_name
 
23
from bzrlib.tests import (
 
24
                          _load_module_by_name,
 
25
                          TestCase,
 
26
                          TestCaseInTempDir,
 
27
                          TestSkipped,
 
28
                          TextTestRunner,
 
29
                          )
23
30
 
24
31
 
25
32
class SelftestTests(TestCase):
35
42
 
36
43
 
37
44
class MetaTestLog(TestCase):
 
45
 
38
46
    def test_logging(self):
39
47
        """Test logs are captured when a test fails."""
40
48
        self.log('a test message')
41
49
        self._log_file.flush()
42
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())