~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: Robert Collins
  • Date: 2006-09-17 21:03:04 UTC
  • mfrom: (2018 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2019.
  • Revision ID: robertc@robertcollins.net-20060917210304-3a697132f5fb68ac
Merge bzr.dev.

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