~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testlog.py

  • Committer: Robert Collins
  • Date: 2005-08-23 10:44:48 UTC
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050823104448-fb5d448e7a5a8ee3
relace runTest with test_foo in blackbox tests

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):
53
 
 
 
50
class SimpleLogTest(BzrTestBase):
54
51
    def checkDelta(self, delta, **kw):
55
52
        """Check the filenames touched by a delta are as expected."""
56
53
        for n in 'added', 'removed', 'renamed', 'modified', 'unchanged':
64
61
            got = [x[0] for x in getattr(delta, n)]
65
62
            self.assertEquals(expected, got)
66
63
 
67
 
    def test_cur_revno(self):
 
64
    
 
65
    def runTest(self):
 
66
        eq = self.assertEquals
 
67
        ass = self.assert_
 
68
        
68
69
        b = Branch('.', init=True)
69
70
 
70
71
        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
 
    def test_cur_revno(self):
87
 
        b = Branch.initialize('.')
88
 
 
89
 
        lf = LogCatcher()
90
 
        b.commit('empty commit')
91
 
        show_log(b, lf, verbose=True, start_revision=1, end_revision=1)
92
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
93
 
                          start_revision=2, end_revision=1) 
94
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
95
 
                          start_revision=1, end_revision=2) 
96
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
97
 
                          start_revision=0, end_revision=2) 
98
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
99
 
                          start_revision=1, end_revision=0) 
100
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
101
 
                          start_revision=-1, end_revision=1) 
102
 
        self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
103
 
                          start_revision=1, end_revision=-1) 
104
 
 
105
 
    def test_simple_log(self):
106
 
        eq = self.assertEquals
107
 
        
108
 
        b = Branch.initialize('.')
109
 
 
110
 
        lf = LogCatcher()
111
72
        show_log(b, lf)
112
73
        # no entries yet
113
74
        eq(lf.logs, [])
127
88
        self.build_tree(['hello'])
128
89
        b.add('hello')
129
90
        b.commit('add one file')
130
 
 
131
 
        lf = StringIO()
132
91
        # log using regular thing
133
 
        show_log(b, LongLogFormatter(lf))
134
 
        lf.seek(0)
135
 
        for l in lf.readlines():
136
 
            self.log(l)
 
92
        show_log(b, LongLogFormatter(self.TEST_LOG))
137
93
 
138
94
        # get log as data structure
139
95
        lf = LogCatcher()
151
107
        self.log('log 2 delta: %r' % d)
152
108
        # self.checkDelta(d, added=['hello'])
153
109
        
154
 
        # commit a log message with control characters
155
 
        msg = "All 8-bit chars: " +  ''.join([unichr(x) for x in range(256)])
156
 
        b.commit(msg)
157
 
        lf = LogCatcher()
158
 
        show_log(b, lf, verbose=True)
159
 
        committed_msg = lf.logs[0].rev.message
160
 
        self.log("escaped commit message: %r", committed_msg)
161
 
        self.assert_(msg != committed_msg)
162
 
        self.assert_(len(committed_msg) > len(msg))