~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Kent Gibson
  • Date: 2007-11-12 13:56:16 UTC
  • mto: (2996.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2997.
  • Revision ID: warthog618@gmail.com-20071112135616-1bvp2zhekdvy0j23
Use normalize_log to more accurately test blackbox log output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
219
219
    return b
220
220
 
221
221
 
 
222
def normalize_log(log):
 
223
    """Replaces the variable lines of logs with fixed lines"""
 
224
    author = 'author: Dolor Sit <test@example.com>'
 
225
    committer = 'committer: Lorem Ipsum <test@example.com>'
 
226
    lines = log.splitlines(True)
 
227
    for idx,line in enumerate(lines):
 
228
        stripped_line = line.lstrip()
 
229
        indent = ' ' * (len(line) - len(stripped_line))
 
230
        if stripped_line.startswith('author:'):
 
231
            lines[idx] = indent + author + '\n'
 
232
        elif stripped_line.startswith('committer:'):
 
233
            lines[idx] = indent + committer + '\n'
 
234
        elif stripped_line.startswith('timestamp:'):
 
235
            lines[idx] = indent + 'timestamp: Just now\n'
 
236
    return ''.join(lines)
 
237
 
 
238
 
222
239
class TestShortLogFormatter(TestCaseWithTransport):
223
240
 
224
241
    def test_trailing_newlines(self):
244
261
 
245
262
class TestLongLogFormatter(TestCaseWithTransport):
246
263
 
247
 
    def normalize_log(self,log):
248
 
        """Replaces the variable lines of logs with fixed lines"""
249
 
        author = 'author: Dolor Sit <test@example.com>'
250
 
        committer = 'committer: Lorem Ipsum <test@example.com>'
251
 
        lines = log.splitlines(True)
252
 
        for idx,line in enumerate(lines):
253
 
            stripped_line = line.lstrip()
254
 
            indent = ' ' * (len(line) - len(stripped_line))
255
 
            if stripped_line.startswith('author:'):
256
 
                lines[idx] = indent + author + '\n'
257
 
            elif stripped_line.startswith('committer:'):
258
 
                lines[idx] = indent + committer + '\n'
259
 
            elif stripped_line.startswith('timestamp:'):
260
 
                lines[idx] = indent + 'timestamp: Just now\n'
261
 
        return ''.join(lines)
262
 
 
263
264
    def test_verbose_log(self):
264
265
        """Verbose log includes changed files
265
266
        
311
312
        sio = self.make_utf8_encoded_stringio()
312
313
        lf = LongLogFormatter(to_file=sio)
313
314
        show_log(b, lf, verbose=True)
314
 
        log = self.normalize_log(sio.getvalue())
 
315
        log = normalize_log(sio.getvalue())
315
316
        self.assertEqualDiff("""\
316
317
------------------------------------------------------------
317
318
revno: 2
367
368
        sio = self.make_utf8_encoded_stringio()
368
369
        lf = LongLogFormatter(to_file=sio)
369
370
        show_log(b, lf, verbose=True)
370
 
        log = self.normalize_log(sio.getvalue())
 
371
        log = normalize_log(sio.getvalue())
371
372
        self.assertEqualDiff("""\
372
373
------------------------------------------------------------
373
374
revno: 2