~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-09 04:51:05 UTC
  • Revision ID: mbp@sourcefrog.net-20050309045105-d02cd410a115da2c
import all docs from arch

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
These are run by ``bzr.doctest``.
29
29
 
30
 
>>> import bzrlib, os
31
 
>>> from bzrlib import ScratchBranch
32
 
>>> bzrlib.commands.cmd_rocks()
 
30
>>> import bzr, bzrlib, os
 
31
>>> bzr.cmd_rocks()
33
32
it sure does!
34
33
 
35
34
Hey, nice place to begin.
40
39
 
41
40
ScratchBranches are initially empty:
42
41
 
43
 
>>> b = bzrlib.ScratchBranch()
 
42
>>> b = bzr.ScratchBranch()
44
43
>>> b.show_status()
45
44
 
46
45
New files in that directory are, it is initially unknown:
104
103
  >>> r = b.get_revision(b.lookup_revision(1))
105
104
  >>> r.message
106
105
  'start hello world'
107
 
  >>> b.write_log(show_timezone='utc')
 
106
  >>> b.write_log(utc=True)
108
107
  ----------------------------------------
109
108
  revno: 1
110
109
  committer: foo@nowhere
111
 
  timestamp: Thu 1970-01-01 00:00:00 +0000
 
110
  timestamp: Thu 1970-01-01 00:00:00 UTC +0000
112
111
  message:
113
112
    start hello world
114
113
 
140
139
Tests for adding subdirectories, etc.
141
140
 
142
141
    >>> b = bzrlib.branch.ScratchBranch()
143
 
    >>> os.mkdir(b.abspath('d1'))
144
 
    >>> os.mkdir(b.abspath('d2'))
145
 
    >>> os.mkdir(b.abspath('d2/d3'))
 
142
    >>> os.mkdir(b._rel('d1'))
 
143
    >>> os.mkdir(b._rel('d2'))
 
144
    >>> os.mkdir(b._rel('d2/d3'))
146
145
    >>> list(b.working_tree().unknowns())
147
146
    ['d1', 'd2']
148
147
 
149
148
Create some files, but they're not seen as unknown yet:
150
149
 
151
 
    >>> file(b.abspath('d1/f1'), 'w').close()
152
 
    >>> file(b.abspath('d2/f2'), 'w').close()
153
 
    >>> file(b.abspath('d2/f3'), 'w').close()
 
150
    >>> file(b._rel('d1/f1'), 'w').close()
 
151
    >>> file(b._rel('d2/f2'), 'w').close()
 
152
    >>> file(b._rel('d2/f3'), 'w').close()
154
153
    >>> [v[0] for v in b.inventory.directories()]
155
154
    ['']
156
155
    >>> list(b.working_tree().unknowns())
170
169
    >>> list(b.working_tree().unknowns())
171
170
    ['d1/f1', 'd2/d3', 'd2/f2', 'd2/f3']
172
171
 
173
 
    >>> b.add('d1/f1')
174
 
    >>> list(b.working_tree().unknowns())
175
 
    ['d2/d3', 'd2/f2', 'd2/f3']
176
 
 
177
 
Tests for ignored files and patterns:
178
 
 
179
 
    >>> b = ScratchBranch(dirs=['src', 'doc'],
180
 
    ...                   files=['configure.in', 'configure',
181
 
    ...                          'doc/configure', 'foo.c',
182
 
    ...                          'foo'])
183
 
    >>> list(b.unknowns())
184
 
    ['configure', 'configure.in', 'doc', 'foo', 'foo.c', 'src']
185
 
    >>> b.add(['doc', 'foo.c', 'src', 'configure.in'])
186
 
    >>> list(b.unknowns())
187
 
    ['configure', 'doc/configure', 'foo']
188
 
    >>> f = file(b.abspath('.bzrignore'), 'w')
189
 
    >>> f.write('./configure\n'
190
 
    ...         './foo\n')
191
 
    >>> f.close()
192
 
    >>> b.add('.bzrignore')
193
 
    >>> list(b.unknowns())
194
 
    ['configure', 'doc/configure', 'foo']
195
172
"""