/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/test_export.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-05-20 17:21:41 UTC
  • mfrom: (6968.2.10 archive)
  • Revision ID: breezy.the.bot@gmail.com-20180520172141-fz1rgat80bbdi77j
Refactor the export API.

Merged from https://code.launchpad.net/~jelmer/brz/archive/+merge/346369

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    tests,
28
28
    )
29
29
from ..export import get_root_name
30
 
from ..export.tar_exporter import export_tarball_generator
 
30
from ..archive.tar import tarball_generator
31
31
from ..sixish import (
32
32
    BytesIO,
33
33
    )
250
250
        tf = tarfile.open('target.tar.bz2')
251
251
        self.assertEqual(["target/a"], tf.getnames())
252
252
 
253
 
    def test_xz_stdout(self):
254
 
        wt = self.make_branch_and_tree('.')
255
 
        self.assertRaises(errors.BzrError, export.export, wt, '-',
256
 
            format="txz")
257
 
 
258
253
    def test_export_tarball_generator(self):
259
254
        wt = self.make_branch_and_tree('.')
260
255
        self.build_tree(['a'])
261
256
        wt.add(["a"])
262
257
        wt.commit("1", timestamp=42)
263
258
        target = BytesIO()
264
 
        ball = tarfile.open(None, "w|", target)
265
 
        wt.lock_read()
266
 
        try:
267
 
            for _ in export_tarball_generator(wt, ball, "bar"):
268
 
                pass
269
 
        finally:
270
 
            wt.unlock()
 
259
        with wt.lock_read():
 
260
            target.writelines(tarball_generator(wt, "bar"))
271
261
        # Ball should now be closed.
272
262
        target.seek(0)
273
263
        ball2 = tarfile.open(None, "r", target)