~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/upstream_import.py

  • Committer: Aaron Bentley
  • Date: 2007-03-09 18:25:10 UTC
  • mto: This revision was merged to the branch mainline in revision 520.
  • Revision ID: abentley@panoramicfeedback.com-20070309182510-fkj1j6t119d1cj5q
Handle broken python tar implementations

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
from bzrlib.bzrdir import BzrDir
10
10
from bzrlib.plugins.bzrtools.upstream_import import (
11
11
    common_directory,
 
12
    import_archive,
12
13
    import_tar,
13
14
    import_zip,
14
15
    import_dir,
17
18
)
18
19
from bzrlib.tests import TestCaseInTempDir
19
20
 
 
21
 
 
22
def import_tar_broken(tree, tar_input):
 
23
    """
 
24
    Import a tarfile with names that that end in //, e.g. Feisty Python 2.5
 
25
    """
 
26
    tar_file = tarfile.open('lala', 'r', tar_input)
 
27
    for member in tar_file.members:
 
28
        if member.name.endswith('/'):
 
29
            member.name += '/'
 
30
    import_archive(tree, tar_file)
 
31
 
 
32
 
20
33
class DirFileWriter(object):
21
34
 
22
35
    def __init__(self, fileobj, mode):
155
168
            return tarfile.open('project-0.1.tar', mode, fileobj)
156
169
        self.archive_test(builder, import_tar)
157
170
 
 
171
    def test_broken_tar(self):
 
172
        def builder(fileobj, mode='w'):
 
173
            return tarfile.open('project-0.1.tar', mode, fileobj)
 
174
        self.archive_test(builder, import_tar_broken, subdir=True)
 
175
 
158
176
    def test_unzip(self):
159
177
        def builder(fileobj, mode='w'):
160
178
            return ZipFileWrapper(fileobj, mode)