~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Neil Martinsen-Burrell
  • Date: 2009-12-11 13:44:05 UTC
  • mto: This revision was merged to the branch mainline in revision 4916.
  • Revision ID: nmb@wartburg.edu-20091211134405-36njvdrqhco95s79
switch should use directory services when creating a branch

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
 
        log = self.get_log()
148
 
        self.assertContainsRe(log, "the unicode character for benzene is")
 
147
        self.assertContainsRe(self._get_log(keep_log_file=True),
 
148
                              "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
 
        log = self.get_log()
154
 
        self.assertContainsRe(log, 'the unicode character')
 
153
        self.assertContainsRe(self._get_log(keep_log_file=True),
 
154
                              '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
 
        log = self.get_log()
161
 
        self.assertContainsRe(log, 'the unicode character')
 
160
        self.assertContainsRe(self._get_log(keep_log_file=True),
 
161
                              '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()
 
180
        log = self._get_log(keep_log_file=True)
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()
 
192
        log = self._get_log(keep_log_file=True)
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*.
206
204
        mutter(u'Writing a greek mu (\xb5) works in a unicode string')
207
205
        mutter('But fails in an ascii string \xb5')
208
206
        mutter('and in an ascii argument: %s', '\xb5')
209
 
        log = self.get_log()
 
207
        log = self._get_log(keep_log_file=True)
210
208
        self.assertContainsRe(log, 'Writing a greek mu')
211
209
        self.assertContainsRe(log, "But fails in an ascii string")
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'))
 
210
        self.assertContainsRe(log, u"ascii argument: \xb5")
217
211
 
218
212
    def test_push_log_file(self):
219
213
        """Can push and pop log file, and this catches mutter messages.