/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2019-09-21 17:08:09 UTC
  • mfrom: (7389 work)
  • mto: This revision was merged to the branch mainline in revision 7390.
  • Revision ID: jelmer@jelmer.uk-20190921170809-ejewbeue585deajo
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
304
304
 
305
305
        self.run_bzr('export ../first.tar -r 1')
306
306
        self.assertTrue(os.path.isfile('../first.tar'))
307
 
        tf = tarfile.open('../first.tar')
308
 
        try:
 
307
        with tarfile.open('../first.tar') as tf:
309
308
            self.assertEqual(['first/hello'], sorted(tf.getnames()))
310
309
            self.assertEqual(b'foo', tf.extractfile('first/hello').read())
311
 
        finally:
312
 
            tf.close()
313
310
 
314
311
        self.run_bzr('export ../first.tar.gz -r 1')
315
312
        self.assertTrue(os.path.isfile('../first.tar.gz'))
320
317
        self.run_bzr('export ../first.tar.tbz2 -r 1')
321
318
        self.assertTrue(os.path.isfile('../first.tar.tbz2'))
322
319
 
323
 
        tf = tarfile.open('../first.tar.tbz2', 'r:bz2')
324
 
        try:
 
320
        with tarfile.open('../first.tar.tbz2', 'r:bz2') as tf:
325
321
            self.assertEqual(['first.tar/hello'], sorted(tf.getnames()))
326
322
            self.assertEqual(b'foo', tf.extractfile('first.tar/hello').read())
327
 
        finally:
328
 
            tf.close()
329
323
        self.run_bzr('export ../first2.tar -r 1 --root pizza')
330
 
        tf = tarfile.open('../first2.tar')
331
 
        try:
 
324
        with tarfile.open('../first2.tar') as tf:
332
325
            self.assertEqual(['pizza/hello'], sorted(tf.getnames()))
333
326
            self.assertEqual(b'foo', tf.extractfile('pizza/hello').read())
334
 
        finally:
335
 
            tf.close()
336
327
 
337
328
    def test_basic_zipfile_export(self):
338
329
        self.example_branch()
340
331
 
341
332
        self.run_bzr('export ../first.zip -r 1')
342
333
        self.assertPathExists('../first.zip')
343
 
        zf = zipfile.ZipFile('../first.zip')
344
 
        try:
 
334
        with zipfile.ZipFile('../first.zip') as zf:
345
335
            self.assertEqual(['first/hello'], sorted(zf.namelist()))
346
336
            self.assertEqual(b'foo', zf.read('first/hello'))
347
 
        finally:
348
 
            zf.close()
349
337
 
350
338
        self.run_bzr('export ../first2.zip -r 1 --root pizza')
351
 
        zf = zipfile.ZipFile('../first2.zip')
352
 
        try:
 
339
        with zipfile.ZipFile('../first2.zip') as zf:
353
340
            self.assertEqual(['pizza/hello'], sorted(zf.namelist()))
354
341
            self.assertEqual(b'foo', zf.read('pizza/hello'))
355
 
        finally:
356
 
            zf.close()
357
342
 
358
343
        self.run_bzr('export ../first-zip --format=zip -r 1')
359
 
        zf = zipfile.ZipFile('../first-zip')
360
 
        try:
 
344
        with zipfile.ZipFile('../first-zip') as zf:
361
345
            self.assertEqual(['first-zip/hello'], sorted(zf.namelist()))
362
346
            self.assertEqual(b'foo', zf.read('first-zip/hello'))
363
 
        finally:
364
 
            zf.close()
365
347
 
366
348
    def test_export_from_outside_branch(self):
367
349
        self.example_branch()