~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
"""
20
20
 
21
21
import os
 
22
import stat
 
23
import sys
22
24
import tarfile
23
25
import zipfile
24
26
 
 
27
from bzrlib.export import (
 
28
    zip_exporter,
 
29
    )
25
30
from bzrlib.tests import TestSkipped
26
31
from bzrlib.tests.blackbox import ExternalBase
27
32
 
95
100
        self.assertEqual(['test/' + fname.encode('utf8')],
96
101
                         sorted(zfile.namelist()))
97
102
 
 
103
    def test_zip_export_directories(self):
 
104
        tree = self.make_branch_and_tree('zip')
 
105
        self.build_tree(['zip/a', 'zip/b/', 'zip/b/c', 'zip/d/'])
 
106
        tree.add(['a', 'b', 'b/c', 'd'])
 
107
        tree.commit('init')
 
108
 
 
109
        os.chdir('zip')
 
110
        self.run_bzr('export', 'test.zip')
 
111
        zfile = zipfile.ZipFile('test.zip')
 
112
        names = sorted(zfile.namelist())
 
113
 
 
114
        # even on win32, zipfile.ZipFile changes all names to use
 
115
        # forward slashes
 
116
        self.assertEqual(['test/a', 'test/b/', 'test/b/c', 'test/d/'], names)
 
117
 
 
118
        file_attr = stat.S_IFREG
 
119
        dir_attr = stat.S_IFDIR | zip_exporter.ZIP_DIRECTORY_BIT
 
120
 
 
121
        a_info = zfile.getinfo(names[0])
 
122
        self.assertEqual(file_attr, a_info.external_attr)
 
123
 
 
124
        b_info = zfile.getinfo(names[1])
 
125
        self.assertEqual(dir_attr, b_info.external_attr)
 
126
 
 
127
        c_info = zfile.getinfo(names[2])
 
128
        self.assertEqual(file_attr, c_info.external_attr)
 
129
 
 
130
        d_info = zfile.getinfo(names[3])
 
131
        self.assertEqual(dir_attr, d_info.external_attr)
 
132
 
98
133
    def test_dir_export(self):
99
134
        tree = self.make_branch_and_tree('dir')
100
135
        self.build_tree(['dir/a'])