~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_export.py

  • Committer: Vincent Ladeuil
  • Date: 2007-06-26 20:32:49 UTC
  • mto: (2581.1.1 cleanup-runbzr)
  • mto: This revision was merged to the branch mainline in revision 2588.
  • Revision ID: v.ladeuil+lp@free.fr-20070626203249-sqm4afiai5dxofum
Deprecate the varargs syntax and fix the tests.

* bzrlib/tests/__init__.py:
(TestCase.run_bzr): Activate the deprecation warning.
(TestCase.run_bzr_error): Add error_regexes to kwargs or run_bzr
get confused.

* bzrlib/tests/blackbox/test_selftest.py:
(TestRunBzr.test_args): Activate.

* bzrlib/tests/blackbox/test_inventory.py:
(TestInventory.assertInventoryEqual): Build the command from args
if not None.

* bzrlib/tests/blackbox/test_ls.py:
(TestLS.ls_equals): Build the command from args if not None.

* bzrlib/tests/blackbox/test_remove_tree.py:
(TestRemoveTree.test_remove_tree_lightweight_checkout_explicit):
Nice catch, we were calling run_bzr instead of run_bzr_error. This
went unnoticed for some time...

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
        tree.add('a')
40
40
 
41
41
        os.chdir('tar')
42
 
        self.run_bzr('ignore', 'something')
 
42
        self.run_bzr('ignore something')
43
43
        tree.commit('1')
44
44
 
45
45
        self.failUnless(tree.has_filename('.bzrignore'))
46
 
        self.run_bzr('export', 'test.tar.gz')
 
46
        self.run_bzr('export test.tar.gz')
47
47
        ball = tarfile.open('test.tar.gz')
48
48
        # Make sure the tarball contains 'a', but does not contain
49
49
        # '.bzrignore'.
60
60
        tree.commit('first')
61
61
 
62
62
        os.chdir('tar')
63
 
        self.run_bzr('export', 'test.tar')
 
63
        self.run_bzr('export test.tar')
64
64
        ball = tarfile.open('test.tar')
65
65
        # all paths are prefixed with the base name of the tarball
66
66
        self.assertEqual(['test/' + fname.encode('utf8')],
72
72
        tree.add('a')
73
73
 
74
74
        os.chdir('zip')
75
 
        self.run_bzr('ignore', 'something')
 
75
        self.run_bzr('ignore something')
76
76
        tree.commit('1')
77
77
 
78
78
        self.failUnless(tree.has_filename('.bzrignore'))
79
 
        self.run_bzr('export', 'test.zip')
 
79
        self.run_bzr('export test.zip')
80
80
 
81
81
        zfile = zipfile.ZipFile('test.zip')
82
82
        # Make sure the zipfile contains 'a', but does not contain
94
94
        tree.commit('first')
95
95
 
96
96
        os.chdir('zip')
97
 
        self.run_bzr('export', 'test.zip')
 
97
        self.run_bzr('export test.zip')
98
98
        zfile = zipfile.ZipFile('test.zip')
99
99
        # all paths are prefixed with the base name of the zipfile
100
100
        self.assertEqual(['test/' + fname.encode('utf8')],
107
107
        tree.commit('init')
108
108
 
109
109
        os.chdir('zip')
110
 
        self.run_bzr('export', 'test.zip')
 
110
        self.run_bzr('export test.zip')
111
111
        zfile = zipfile.ZipFile('test.zip')
112
112
        names = sorted(zfile.namelist())
113
113
 
136
136
        tree.add('a')
137
137
 
138
138
        os.chdir('dir')
139
 
        self.run_bzr('ignore', 'something')
 
139
        self.run_bzr('ignore something')
140
140
        tree.commit('1')
141
141
 
142
142
        self.failUnless(tree.has_filename('.bzrignore'))
143
 
        self.run_bzr('export', 'direxport')
 
143
        self.run_bzr('export direxport')
144
144
 
145
145
        files = sorted(os.listdir('direxport'))
146
146
        # Make sure the exported directory contains 'a', but does not contain
163
163
        os.chdir('branch')
164
164
 
165
165
        # Directory exports
166
 
        self.run_bzr('export', '../latest')
 
166
        self.run_bzr('export ../latest')
167
167
        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('../latest')))
168
168
        self.check_file_contents('../latest/goodbye', 'baz')
169
 
        self.run_bzr('export', '../first', '-r', '1')
 
169
        self.run_bzr('export ../first -r 1')
170
170
        self.assertEqual(['hello'], sorted(os.listdir('../first')))
171
171
        self.check_file_contents('../first/hello', 'foo')
172
172
 
173
173
        # Even with .gz and .bz2 it is still a directory
174
 
        self.run_bzr('export', '../first.gz', '-r', '1')
 
174
        self.run_bzr('export ../first.gz -r 1')
175
175
        self.check_file_contents('../first.gz/hello', 'foo')
176
 
        self.run_bzr('export', '../first.bz2', '-r', '1')
 
176
        self.run_bzr('export ../first.bz2 -r 1')
177
177
        self.check_file_contents('../first.bz2/hello', 'foo')
178
178
 
179
179
    def test_basic_tarfile_export(self):
180
180
        self.example_branch()
181
181
        os.chdir('branch')
182
182
 
183
 
        self.run_bzr('export', '../first.tar', '-r', '1')
 
183
        self.run_bzr('export ../first.tar -r 1')
184
184
        self.failUnless(os.path.isfile('../first.tar'))
185
185
        tf = tarfile.open('../first.tar')
186
186
        try:
189
189
        finally:
190
190
            tf.close()
191
191
 
192
 
        self.run_bzr('export', '../first.tar.gz', '-r', '1')
 
192
        self.run_bzr('export ../first.tar.gz -r 1')
193
193
        self.failUnless(os.path.isfile('../first.tar.gz'))
194
 
        self.run_bzr('export', '../first.tbz2', '-r', '1')
 
194
        self.run_bzr('export ../first.tbz2 -r 1')
195
195
        self.failUnless(os.path.isfile('../first.tbz2'))
196
 
        self.run_bzr('export', '../first.tar.bz2', '-r', '1')
 
196
        self.run_bzr('export ../first.tar.bz2 -r 1')
197
197
        self.failUnless(os.path.isfile('../first.tar.bz2'))
198
 
        self.run_bzr('export', '../first.tar.tbz2', '-r', '1')
 
198
        self.run_bzr('export ../first.tar.tbz2 -r 1')
199
199
        self.failUnless(os.path.isfile('../first.tar.tbz2'))
200
200
 
201
201
        tf = tarfile.open('../first.tar.tbz2', 'r:bz2')
204
204
            self.assertEqual('foo', tf.extractfile('first.tar/hello').read())
205
205
        finally:
206
206
            tf.close()
207
 
        self.run_bzr('export', '../first2.tar', '-r', '1', '--root', 'pizza')
 
207
        self.run_bzr('export ../first2.tar -r 1 --root pizza')
208
208
        tf = tarfile.open('../first2.tar')
209
209
        try:
210
210
            self.assertEqual(['pizza/hello'], sorted(tf.getnames()))
216
216
        self.example_branch()
217
217
        os.chdir('branch')
218
218
 
219
 
        self.run_bzr('export', '../first.zip', '-r', '1')
 
219
        self.run_bzr('export ../first.zip -r 1')
220
220
        self.failUnlessExists('../first.zip')
221
221
        zf = zipfile.ZipFile('../first.zip')
222
222
        try:
225
225
        finally:
226
226
            zf.close()
227
227
 
228
 
        self.run_bzr('export', '../first2.zip', '-r', '1', '--root', 'pizza')
 
228
        self.run_bzr('export ../first2.zip -r 1 --root pizza')
229
229
        zf = zipfile.ZipFile('../first2.zip')
230
230
        try:
231
231
            self.assertEqual(['pizza/hello'], sorted(zf.namelist()))
233
233
        finally:
234
234
            zf.close()
235
235
        
236
 
        self.run_bzr('export', '../first-zip', '--format=zip', '-r', '1')
 
236
        self.run_bzr('export ../first-zip --format=zip -r 1')
237
237
        zf = zipfile.ZipFile('../first-zip')
238
238
        try:
239
239
            self.assertEqual(['first-zip/hello'], sorted(zf.namelist()))
245
245
        self.example_branch()
246
246
 
247
247
        # Use directory exports to test stating the branch location
248
 
        self.run_bzr('export', 'latest', 'branch')
 
248
        self.run_bzr('export latest branch')
249
249
        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
250
250
        self.check_file_contents('latest/goodbye', 'baz')
251
 
        self.run_bzr('export', 'first', '-r', '1', 'branch')
 
251
        self.run_bzr('export first -r 1 branch')
252
252
        self.assertEqual(['hello'], sorted(os.listdir('first')))
253
253
        self.check_file_contents('first/hello', 'foo')