~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-12-23 00:59:10 UTC
  • mfrom: (4794.1.21 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091223005910-zatr8ajlw8ul6d6s
(robertc) Add testtools 0.9.2 as a hard dependency to run the test
        suite, improving debug output on selftest --parallel,
        reducing code size and adding support for assertThat. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
    def test_trace_unicode(self):
145
145
        """Write Unicode to trace log"""
146
146
        self.log(u'the unicode character for benzene is \N{BENZENE RING}')
147
 
        self.assertContainsRe(self._get_log(keep_log_file=True),
148
 
                              "the unicode character for benzene is")
 
147
        log = self.get_log()
 
148
        self.assertContainsRe(log, "the unicode character for benzene is")
149
149
 
150
150
    def test_trace_argument_unicode(self):
151
151
        """Write a Unicode argument to the trace log"""
152
152
        mutter(u'the unicode character for benzene is %s', u'\N{BENZENE RING}')
153
 
        self.assertContainsRe(self._get_log(keep_log_file=True),
154
 
                              'the unicode character')
 
153
        log = self.get_log()
 
154
        self.assertContainsRe(log, 'the unicode character')
155
155
 
156
156
    def test_trace_argument_utf8(self):
157
157
        """Write a Unicode argument to the trace log"""
158
158
        mutter(u'the unicode character for benzene is %s',
159
159
               u'\N{BENZENE RING}'.encode('utf-8'))
160
 
        self.assertContainsRe(self._get_log(keep_log_file=True),
161
 
                              'the unicode character')
 
160
        log = self.get_log()
 
161
        self.assertContainsRe(log, 'the unicode character')
162
162
 
163
163
    def test_report_broken_pipe(self):
164
164
        try:
177
177
    def test_mutter_callsite_1(self):
178
178
        """mutter_callsite can capture 1 level of stack frame."""
179
179
        mutter_callsite(1, "foo %s", "a string")
180
 
        log = self._get_log(keep_log_file=True)
 
180
        log = self.get_log()
181
181
        # begin with the message
182
182
        self.assertLogStartsWith(log, 'foo a string\nCalled from:\n')
183
183
        # should show two frame: this frame and the one above
189
189
    def test_mutter_callsite_2(self):
190
190
        """mutter_callsite can capture 2 levels of stack frame."""
191
191
        mutter_callsite(2, "foo %s", "a string")
192
 
        log = self._get_log(keep_log_file=True)
 
192
        log = self.get_log()
193
193
        # begin with the message
194
194
        self.assertLogStartsWith(log, 'foo a string\nCalled from:\n')
195
195
        # should show two frame: this frame and the one above
201
201
    def test_mutter_never_fails(self):
202
202
        # Even if the decode/encode stage fails, mutter should not
203
203
        # raise an exception
 
204
        # This test checks that mutter doesn't fail; the current behaviour
 
205
        # is that it doesn't fail *and writes non-utf8*.
204
206
        mutter(u'Writing a greek mu (\xb5) works in a unicode string')
205
207
        mutter('But fails in an ascii string \xb5')
206
208
        mutter('and in an ascii argument: %s', '\xb5')
207
 
        log = self._get_log(keep_log_file=True)
 
209
        log = self.get_log()
208
210
        self.assertContainsRe(log, 'Writing a greek mu')
209
211
        self.assertContainsRe(log, "But fails in an ascii string")
210
 
        self.assertContainsRe(log, u"ascii argument: \xb5")
 
212
        # However, the log content object does unicode replacement on reading
 
213
        # to let it get unicode back where good data has been written. So we
 
214
        # have to do a replaceent here as well.
 
215
        self.assertContainsRe(log, "ascii argument: \xb5".decode('utf8',
 
216
            'replace'))
211
217
 
212
218
    def test_push_log_file(self):
213
219
        """Can push and pop log file, and this catches mutter messages.