~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:
20
20
import sys
21
21
import unittest
22
22
 
23
 
from bzrlib.tests import TestCase, _load_module_by_name, \
24
 
        TestSkipped
25
 
import bzrlib.tests
 
23
from bzrlib.tests import (
 
24
                          _load_module_by_name,
 
25
                          TestCase,
 
26
                          TestCaseInTempDir,
 
27
                          TestSkipped,
 
28
                          TextTestRunner,
 
29
                          )
26
30
 
27
31
 
28
32
class SelftestTests(TestCase):
38
42
 
39
43
 
40
44
class MetaTestLog(TestCase):
 
45
 
41
46
    def test_logging(self):
42
47
        """Test logs are captured when a test fails."""
43
48
        self.log('a test message')
45
50
        self.assertContainsRe(self._get_log(), 'a test message\n')
46
51
 
47
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
 
48
65
class TestSkippedTest(TestCase):
49
66
    """Try running a test which is skipped, make sure it's reported properly."""
50
67
    def test_skipped_test(self):
51
68
        # must be hidden in here so it's not run as a real test
52
69
        def skipping_test():
53
70
            raise TestSkipped('test intentionally skipped')
54
 
        runner = bzrlib.tests.TextTestRunner(stream=self._log_file)
 
71
        runner = TextTestRunner(stream=self._log_file)
55
72
        test = unittest.FunctionTestCase(skipping_test)
56
73
        result = runner.run(test)
57
74
        self.assertTrue(result.wasSuccessful())