~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testlog.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-08-27 04:42:41 UTC
  • mfrom: (1092.1.43)
  • mto: (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1178.
  • Revision ID: aaron.bentley@utoronto.ca-20050827044241-23d676133b9fc981
Merge of robertc@robertcollins.net-20050826013321-52eee1f1da679ee9

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
18
 
from cStringIO import StringIO
19
18
 
20
 
from bzrlib.selftest import BzrTestBase, TestCaseInTempDir
 
19
from bzrlib.selftest import BzrTestBase
21
20
from bzrlib.log import LogFormatter, show_log, LongLogFormatter
22
21
from bzrlib.branch import Branch
23
 
from bzrlib.errors import InvalidRevisionNumber
24
22
 
25
23
class _LogEntry(object):
26
24
    # should probably move into bzrlib.log?
49
47
        self.logs.append(le)
50
48
 
51
49
 
52
 
class SimpleLogTest(TestCaseInTempDir):
 
50
class SimpleLogTest(BzrTestBase):
53
51
 
54
52
    def checkDelta(self, delta, **kw):
55
53
        """Check the filenames touched by a delta are as expected."""
64
62
            got = [x[0] for x in getattr(delta, n)]
65
63
            self.assertEquals(expected, got)
66
64
 
67
 
    def test_cur_revno(self):
68
 
        b = Branch('.', init=True)
69
 
 
70
 
        lf = LogCatcher()
71
 
        b.commit('empty commit')
72
 
        show_log(b, lf, verbose=True, start_revision=1, end_revision=1)
73
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
74
 
                          start_revision=2, end_revision=1) 
75
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
76
 
                          start_revision=1, end_revision=2) 
77
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
78
 
                          start_revision=0, end_revision=2) 
79
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
80
 
                          start_revision=1, end_revision=0) 
81
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
82
 
                          start_revision=-1, end_revision=1) 
83
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
84
 
                          start_revision=1, end_revision=-1) 
85
 
 
86
65
    def test_simple_log(self):
87
66
        eq = self.assertEquals
 
67
        ass = self.assert_
88
68
        
89
69
        b = Branch('.', init=True)
90
70
 
108
88
        self.build_tree(['hello'])
109
89
        b.add('hello')
110
90
        b.commit('add one file')
111
 
 
112
 
        lf = StringIO()
113
91
        # log using regular thing
114
 
        show_log(b, LongLogFormatter(lf))
115
 
        lf.seek(0)
116
 
        for l in lf.readlines():
117
 
            self.log(l)
 
92
        show_log(b, LongLogFormatter(self.TEST_LOG))
118
93
 
119
94
        # get log as data structure
120
95
        lf = LogCatcher()