~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_export.py

  • Committer: Jelmer Vernooij
  • Date: 2011-03-13 21:11:26 UTC
  • mto: This revision was merged to the branch mainline in revision 5724.
  • Revision ID: jelmer@samba.org-20110313211126-lg8j264afs48dspq
Add test for export_tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
"""Tests for bzrlib.export."""
 
18
 
 
19
from cStringIO import StringIO
17
20
import os
18
21
import tarfile
19
22
import time
23
26
    export,
24
27
    tests,
25
28
    )
 
29
from bzrlib.export.tar_exporter import export_tarball
26
30
 
27
31
 
28
32
class TestDirExport(tests.TestCaseWithTransport):
172
176
        wt = self.make_branch_and_tree('.')
173
177
        self.assertRaises(errors.BzrError, export.export, wt, '-',
174
178
            format="txz")
 
179
 
 
180
    def test_export_tarball(self):
 
181
        wt = self.make_branch_and_tree('.')
 
182
        self.build_tree(['a'])
 
183
        wt.add(["a"])
 
184
        wt.commit("1", timestamp=42)
 
185
        target = StringIO()
 
186
        ball = tarfile.open(None, "w|", target)
 
187
        wt.lock_read()
 
188
        try:
 
189
            export_tarball(wt, ball, "bar", subdir=None)
 
190
        finally:
 
191
            wt.unlock()
 
192
        self.assertEquals(["bar/a"], ball.getnames())
 
193
        ball.close()