/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

  • Committer: John Arbash Meinel
  • Date: 2006-10-06 05:53:44 UTC
  • mfrom: (2063 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2071.
  • Revision ID: john@arbash-meinel.com-20061006055344-e73b97b7c6ca6e72
[merge] bzr.dev 2063

Show diffs side-by-side

added added

removed removed

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