~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-19 23:50:21 UTC
  • Revision ID: mbp@sourcefrog.net-20050319235021-a4a900883ea8e2d8
better notes on how to install

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
 
>>> from bzrlib.osutils import isdir, isfile
 
30
>>> import bzr, bzrlib, os
33
31
>>> bzrlib.commands.cmd_rocks()
34
32
it sure does!
35
33
 
141
139
Tests for adding subdirectories, etc.
142
140
 
143
141
    >>> b = bzrlib.branch.ScratchBranch()
144
 
    >>> os.mkdir(b.abspath('d1'))
145
 
    >>> os.mkdir(b.abspath('d2'))
146
 
    >>> 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'))
147
145
    >>> list(b.working_tree().unknowns())
148
146
    ['d1', 'd2']
149
147
 
150
148
Create some files, but they're not seen as unknown yet:
151
149
 
152
 
    >>> file(b.abspath('d1/f1'), 'w').close()
153
 
    >>> file(b.abspath('d2/f2'), 'w').close()
154
 
    >>> 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()
155
153
    >>> [v[0] for v in b.inventory.directories()]
156
154
    ['']
157
155
    >>> list(b.working_tree().unknowns())
163
161
    >>> [v[0] for v in b.inventory.directories()]
164
162
    ['', 'd1']
165
163
    >>> list(b.working_tree().unknowns())
166
 
    ['d2', 'd1/f1']
 
164
    ['d1/f1', 'd2']
167
165
    >>> # d2 comes first because it's in the top directory
168
166
 
169
167
    >>> b.add('d2')
171
169
    >>> list(b.working_tree().unknowns())
172
170
    ['d1/f1', 'd2/d3', 'd2/f2', 'd2/f3']
173
171
 
174
 
    >>> b.add('d1/f1')
175
 
    >>> list(b.working_tree().unknowns())
176
 
    ['d2/d3', 'd2/f2', 'd2/f3']
177
 
 
178
 
Tests for ignored files and patterns:
179
 
 
180
 
    >>> b = ScratchBranch(dirs=['src', 'doc'],
181
 
    ...                   files=['configure.in', 'configure',
182
 
    ...                          'doc/configure', 'foo.c',
183
 
    ...                          'foo'])
184
 
    >>> list(b.unknowns())
185
 
    ['configure', 'configure.in', 'doc', 'foo', 'foo.c', 'src']
186
 
    >>> b.add(['doc', 'foo.c', 'src', 'configure.in'])
187
 
    >>> list(b.unknowns())
188
 
    ['configure', 'foo', 'doc/configure']
189
 
    >>> f = file(b.abspath('.bzrignore'), 'w')
190
 
    >>> f.write('./configure\n'
191
 
    ...         './foo\n')
192
 
    >>> f.close()
193
 
    >>> b.add('.bzrignore')
194
 
    >>> list(b.unknowns())
195
 
    ['doc/configure']
196
 
    >>> b.commit("commit 1")
197
 
    >>> list(b.unknowns())
198
 
    ['doc/configure']
199
 
    >>> b.add("doc/configure")
200
 
    >>> b.commit("commit more")
201
 
    >>> del b
202
 
 
203
 
Renames, etc:
204
 
 
205
 
    >>> b = ScratchBranch(files=['foo'], dirs=['subdir'])
206
 
    >>> b.add(['foo', 'subdir'])
207
 
    >>> b.commit('add foo')
208
 
    >>> list(b.unknowns())
209
 
    []
210
 
    >>> b.move(['foo'], 'subdir')
211
 
    foo => subdir/foo
212
 
    >>> b.show_status()
213
 
    R       foo => subdir/foo
214
 
    >>> bzrlib.commands.cmd_renames(b.base)
215
 
    foo => subdir/foo
216
 
    >>> b.commit("move foo to subdir")
217
 
    >>> isfile(b.abspath('foo'))
218
 
    False
219
 
    >>> isfile(b.abspath('subdir/foo'))
220
 
    True
221
 
 
222
172
"""