/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        errors.BzrNewError.__init__(self, foo=foo, bar=bar)
69
69
 
70
70
 
 
71
class ErrorWithBadFormat(errors.BzrNewError):
 
72
    """One format specifier: %(thing)s"""
 
73
 
 
74
 
71
75
class TestErrorFormatting(TestCase):
72
76
    
73
77
    def test_always_str(self):
79
83
        # returned from e.__str__(), and it has non ascii characters
80
84
        s = str(e)
81
85
        self.assertEqual('Pass through \xc2\xb5 and bar', s)
 
86
 
 
87
    def test_mismatched_format_args(self):
 
88
        # Even though ErrorWithBadFormat's format string does not match the
 
89
        # arguments we constructing it with, we can still stringify an instance
 
90
        # of this exception. The resulting string will say its unprintable.
 
91
        e = ErrorWithBadFormat(not_thing='x')
 
92
        self.assertStartsWith(
 
93
            str(e), 'Unprintable exception ErrorWithBadFormat(')
 
94
 
 
95
 
 
96
class TestSpecificErrors(TestCase):
 
97
    
 
98
    def test_transport_not_possible(self):
 
99
        e = errors.TransportNotPossible('readonly', 'original error')
 
100
        self.assertEqual('Transport operation not possible:'
 
101
                         ' readonly original error', str(e))