~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

(gz) Backslash escape selftest output when printing to non-unicode consoles
 (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
1282
1282
        result = self.run_test_runner(runner, test)
1283
1283
        self.assertLength(1, calls)
1284
1284
 
 
1285
    def test_unicode_test_output_on_ascii_stream(self):
 
1286
        """Showing results should always succeed even on an ascii console"""
 
1287
        class FailureWithUnicode(tests.TestCase):
 
1288
            def test_log_unicode(self):
 
1289
                self.log(u"\u2606")
 
1290
                self.fail("Now print that log!")
 
1291
        out = StringIO()
 
1292
        self.overrideAttr(osutils, "get_terminal_encoding",
 
1293
            lambda trace=False: "ascii")
 
1294
        result = self.run_test_runner(tests.TextTestRunner(stream=out),
 
1295
            FailureWithUnicode("test_log_unicode"))
 
1296
        self.assertContainsRe(out.getvalue(),
 
1297
            "Text attachment: log\n"
 
1298
            "-+\n"
 
1299
            "\d+\.\d+  \\\\u2606\n"
 
1300
            "-+\n")
 
1301
 
1285
1302
 
1286
1303
class SampleTestCase(tests.TestCase):
1287
1304