~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests.py

  • Committer: Martin Pool
  • Date: 2005-04-28 07:24:55 UTC
  • Revision ID: mbp@sourcefrog.net-20050428072453-7b99afa993a1e549
todo

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 bzr, bzrlib, os
 
30
>>> import bzrlib, os
 
31
>>> from bzrlib import ScratchBranch
 
32
>>> from bzrlib.osutils import isdir, isfile
31
33
>>> bzrlib.commands.cmd_rocks()
32
34
it sure does!
33
35
 
139
141
Tests for adding subdirectories, etc.
140
142
 
141
143
    >>> b = bzrlib.branch.ScratchBranch()
142
 
    >>> os.mkdir(b._rel('d1'))
143
 
    >>> os.mkdir(b._rel('d2'))
144
 
    >>> os.mkdir(b._rel('d2/d3'))
 
144
    >>> os.mkdir(b.abspath('d1'))
 
145
    >>> os.mkdir(b.abspath('d2'))
 
146
    >>> os.mkdir(b.abspath('d2/d3'))
145
147
    >>> list(b.working_tree().unknowns())
146
148
    ['d1', 'd2']
147
149
 
148
150
Create some files, but they're not seen as unknown yet:
149
151
 
150
 
    >>> file(b._rel('d1/f1'), 'w').close()
151
 
    >>> file(b._rel('d2/f2'), 'w').close()
152
 
    >>> file(b._rel('d2/f3'), 'w').close()
 
152
    >>> file(b.abspath('d1/f1'), 'w').close()
 
153
    >>> file(b.abspath('d2/f2'), 'w').close()
 
154
    >>> file(b.abspath('d2/f3'), 'w').close()
153
155
    >>> [v[0] for v in b.inventory.directories()]
154
156
    ['']
155
157
    >>> list(b.working_tree().unknowns())
161
163
    >>> [v[0] for v in b.inventory.directories()]
162
164
    ['', 'd1']
163
165
    >>> list(b.working_tree().unknowns())
164
 
    ['d1/f1', 'd2']
 
166
    ['d2', 'd1/f1']
165
167
    >>> # d2 comes first because it's in the top directory
166
168
 
167
169
    >>> b.add('d2')
169
171
    >>> list(b.working_tree().unknowns())
170
172
    ['d1/f1', 'd2/d3', 'd2/f2', 'd2/f3']
171
173
 
 
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
 
172
222
"""