/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/blackbox/test_log.py

Use a data factory for commit properties and reduce code duplication.

* bzrlib/tests/test_log.py:
(TestLogMixin.wt_commit): Helper acting as a data factory for
commit properties.
(TestCaseForLogFormatter): Use TestLogMixin and wt_commit()
(TestCaseForLogFormatter.assertFormatterResult): Get rid of
normalize_log() use.
(TestCaseForLogFormatter, TestShortLogFormatterWithMergeRevisions,
TestLongLogFormatter, TestLineLogFormatter, TestGetViewRevisions,
TestHistoryChange, TestLogWithBugs): Use wt_commit() and stop
using run_bzr().

* bzrlib/tests/blackbox/test_log.py:
(TestLog): Use test_log.TestLogMixin and get rid of
commit_options().
(TestLogMerges.make_branches_with_merges,
TestLogDiff.make_branch_with_diffs): Use wt_commit().

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    )
34
34
 
35
35
 
36
 
class TestLog(tests.TestCaseWithTransport):
37
 
 
38
 
    def setUp(self):
39
 
        super(TestLog, self).setUp()
40
 
        self.timezone = 0 # UTC
41
 
        self.timestamp = 1132617600 # Mon 2005-11-22 00:00:00 +0000
 
36
class TestLog(tests.TestCaseWithTransport, test_log.TestLogMixin):
42
37
 
43
38
    def make_minimal_branch(self, path='.', format=None):
44
39
        tree = self.make_branch_and_tree(path, format=format)
69
64
        tree.commit(message='merge')
70
65
        return tree
71
66
 
72
 
    def commit_options(self):
73
 
        """Use some mostly fixed values for commits to simplify tests.
74
 
 
75
 
        Tests can use this function to get some commit attributes. The time
76
 
        stamp is incremented at each commit.
77
 
        """
78
 
        self.timestamp += 1 # 1 second between each commit
79
 
        return dict(committer='Lorem Ipsum <joe@foo.com>',
80
 
                 timezone=self.timezone,
81
 
                 timestamp=self.timestamp,
82
 
                 )
83
 
 
84
67
    def check_log(self, expected, args, working_dir='level0'):
85
68
        out, err = self.run_bzr(['log', '--timezone', 'utc'] + args,
86
69
                                working_dir=working_dir)
422
405
 
423
406
    def make_branches_with_merges(self):
424
407
        level0 = self.make_branch_and_tree('level0')
425
 
        level0.commit(message='in branch level0', **self.commit_options())
426
 
 
 
408
        self.wt_commit(level0, 'in branch level0')
427
409
        level1 = level0.bzrdir.sprout('level1').open_workingtree()
428
 
        level1.commit(message='in branch level1', **self.commit_options())
429
 
 
 
410
        self.wt_commit(level1, 'in branch level1')
430
411
        level2 = level1.bzrdir.sprout('level2').open_workingtree()
431
 
        level2.commit(message='in branch level2', **self.commit_options())
432
 
 
 
412
        self.wt_commit(level2, 'in branch level2')
433
413
        level1.merge_from_branch(level2.branch)
434
 
        level1.commit(message='merge branch level2', **self.commit_options())
435
 
 
 
414
        self.wt_commit(level1, 'merge branch level2')
436
415
        level0.merge_from_branch(level1.branch)
437
 
        level0.commit(message='merge branch level1', **self.commit_options())
 
416
        self.wt_commit(level0, 'merge branch level1')
438
417
 
439
418
    def test_merges_are_indented_by_level(self):
440
419
        self.run_bzr(['log', '-n0'], working_dir='level0')
506
485
        self.build_tree(['level0/file1', 'level0/file2'])
507
486
        level0.add('file1')
508
487
        level0.add('file2')
509
 
        level0.commit(message='in branch level0', **self.commit_options())
 
488
        self.wt_commit(level0, 'in branch level0')
510
489
 
511
490
        level1 = level0.bzrdir.sprout('level1').open_workingtree()
512
491
        self.build_tree_contents([('level1/file2', 'hello\n')])
513
 
        level1.commit(message='in branch level1', **self.commit_options())
 
492
        self.wt_commit(level1, 'in branch level1')
514
493
        level0.merge_from_branch(level1.branch)
515
 
        level0.commit(message='merge branch level1', **self.commit_options())
 
494
        self.wt_commit(level0, 'merge branch level1')
516
495
 
517
496
    def _diff_file1_revno1(self):
518
497
        return """=== added file 'file1'
519
498
--- file1\t1970-01-01 00:00:00 +0000
520
 
+++ file1\t2005-11-22 00:00:01 +0000
 
499
+++ file1\t2005-11-22 00:00:00 +0000
521
500
@@ -0,0 +1,1 @@
522
501
+contents of level0/file1
523
502
 
525
504
 
526
505
    def _diff_file2_revno2(self):
527
506
        return """=== modified file 'file2'
528
 
--- file2\t2005-11-22 00:00:01 +0000
529
 
+++ file2\t2005-11-22 00:00:02 +0000
 
507
--- file2\t2005-11-22 00:00:00 +0000
 
508
+++ file2\t2005-11-22 00:00:01 +0000
530
509
@@ -1,1 +1,1 @@
531
510
-contents of level0/file2
532
511
+hello
535
514
 
536
515
    def _diff_file2_revno1_1_1(self):
537
516
        return """=== modified file 'file2'
538
 
--- file2\t2005-11-22 00:00:01 +0000
539
 
+++ file2\t2005-11-22 00:00:02 +0000
 
517
--- file2\t2005-11-22 00:00:00 +0000
 
518
+++ file2\t2005-11-22 00:00:01 +0000
540
519
@@ -1,1 +1,1 @@
541
520
-contents of level0/file2
542
521
+hello
546
525
    def _diff_file2_revno1(self):
547
526
        return """=== added file 'file2'
548
527
--- file2\t1970-01-01 00:00:00 +0000
549
 
+++ file2\t2005-11-22 00:00:01 +0000
 
528
+++ file2\t2005-11-22 00:00:00 +0000
550
529
@@ -0,0 +1,1 @@
551
530
+contents of level0/file2
552
531