~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Guillermo Gonzalez
  • Date: 2008-07-09 20:15:29 UTC
  • mto: (3542.1.1 logdisplayers)
  • mto: This revision was merged to the branch mainline in revision 3556.
  • Revision ID: guillo.gonzo@gmail.com-20080709201529-sssx8g4paymb3qzs
 * fixed typo LogFormatter.show_properties in docstring
 * added test for bad argument in property handler TestLongLogFormatter.test_properties_handler_bad_argument
 * moved NEWS entry from BUGFIXES to IMPROVEMENTS

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        log.properties_handler_registry = registry.Registry()
50
50
        
51
51
    def _cleanup(self):
52
 
        super(TestLongLogFormatter, self).tearDown()
 
52
        super(TestCaseWithoutPropsHandler, self)._cleanup()
53
53
        # restore the custom properties handler registry
54
54
        log.properties_handler_registry = \
55
55
            self.properties_handler_registry
586
586
        b = wt.branch
587
587
        self.build_tree(['a'])
588
588
        wt.add('a')
589
 
        b.nick = 'test_author_log'
 
589
        b.nick = 'test_properties_in_log'
590
590
        wt.commit(message='add a',
591
591
                  timestamp=1132711707,
592
592
                  timezone=36000,
611
611
test_prop: test_value
612
612
author: John Doe <jdoe@example.com>
613
613
committer: Lorem Ipsum <test@example.com>
614
 
branch nick: test_author_log
 
614
branch nick: test_properties_in_log
615
615
timestamp: Wed 2005-11-23 12:08:27 +1000
616
616
message:
617
617
  add a
645
645
        finally:
646
646
            log.properties_handler_registry.remove(
647
647
                'trivial_custom_prop_handler')
 
648
                
 
649
    def test_properties_handler_bad_argument(self):
 
650
        wt = self.make_branch_and_tree('.')
 
651
        b = wt.branch
 
652
        self.build_tree(['a'])
 
653
        wt.add('a')
 
654
        b.nick = 'test_author_log'
 
655
        wt.commit(message='add a',
 
656
                  timestamp=1132711707,
 
657
                  timezone=36000,
 
658
                  committer='Lorem Ipsum <test@example.com>',
 
659
                  author='John Doe <jdoe@example.com>',
 
660
                  revprops={'a_prop':'test_value'})
 
661
        sio = StringIO()
 
662
        formatter = LongLogFormatter(to_file=sio)
 
663
        try:
 
664
            def bad_argument_prop_handler(revision):
 
665
                return {'custom_prop_name':revision.properties['a_prop']}
 
666
                
 
667
            log.properties_handler_registry.register(
 
668
                'bad_argument_prop_handler', 
 
669
                bad_argument_prop_handler)
 
670
            
 
671
            self.assertRaises(AttributeError, formatter.show_properties, 
 
672
                'a revision', '')
 
673
            
 
674
            revision = b.repository.get_revision(b.last_revision())
 
675
            formatter.show_properties(revision, '')
 
676
            self.assertEqualDiff(sio.getvalue(),
 
677
                '''custom_prop_name: test_value\n''')
 
678
        finally:
 
679
            log.properties_handler_registry.remove(
 
680
                'bad_argument_prop_handler')
648
681
 
649
682
 
650
683
class TestLineLogFormatter(TestCaseWithTransport):