~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_win32utils.py

  • Committer: Martin Pool
  • Date: 2011-07-04 21:10:37 UTC
  • mto: (6034.1.1 filter-tree)
  • mto: This revision was merged to the branch mainline in revision 6035.
  • Revision ID: mbp@canonical.com-20110704211037-ro3417imj3oqnqxp
Support exporting tarballs from ContentFilterTree

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    win32utils,
25
25
    )
26
26
from bzrlib.tests import (
 
27
    Feature,
27
28
    TestCase,
28
29
    TestCaseInTempDir,
29
30
    TestSkipped,
 
31
    UnicodeFilenameFeature,
30
32
    )
31
33
from bzrlib.tests.features import backslashdir_feature
32
34
from bzrlib.win32utils import glob_expand, get_app_path
33
 
from bzrlib.tests import (
34
 
    features,
35
 
    )
36
 
 
37
 
 
38
 
Win32RegistryFeature = features.ModuleAvailableFeature('_winreg')
39
 
CtypesFeature = features.ModuleAvailableFeature('ctypes')
40
 
Win32comShellFeature = features.ModuleAvailableFeature('win32com.shell')
41
 
Win32ApiFeature = features.ModuleAvailableFeature('win32api') 
 
35
 
 
36
 
 
37
class _RequiredModuleFeature(Feature):
 
38
 
 
39
    def __init__(self, mod_name):
 
40
        self.mod_name = mod_name
 
41
        super(_RequiredModuleFeature, self).__init__()
 
42
 
 
43
    def _probe(self):
 
44
        try:
 
45
            __import__(self.mod_name)
 
46
            return True
 
47
        except ImportError:
 
48
            return False
 
49
 
 
50
    def feature_name(self):
 
51
        return self.mod_name
 
52
 
 
53
Win32RegistryFeature = _RequiredModuleFeature('_winreg')
 
54
CtypesFeature = _RequiredModuleFeature('ctypes')
 
55
Win32comShellFeature = _RequiredModuleFeature('win32com.shell')
 
56
Win32ApiFeature = _RequiredModuleFeature('win32api') 
42
57
 
43
58
 
44
59
# Tests
63
78
                         'd/', 'd/d1', 'd/d2', 'd/e/', 'd/e/e1'])
64
79
 
65
80
    def build_unicode_tree(self):
66
 
        self.requireFeature(features.UnicodeFilenameFeature)
 
81
        self.requireFeature(UnicodeFilenameFeature)
67
82
        self.build_tree([u'\u1234', u'\u1234\u1234', u'\u1235/',
68
83
                         u'\u1235/\u1235'])
69
84
 
248
263
 
249
264
    def test_unicode_dir(self):
250
265
        # we should handle unicode paths without errors
251
 
        self.requireFeature(features.UnicodeFilenameFeature)
 
266
        self.requireFeature(UnicodeFilenameFeature)
252
267
        os.mkdir(u'\u1234')
253
268
        win32utils.set_file_attr_hidden(u'\u1234')
254
269
 
255
270
    def test_dot_bzr_in_unicode_dir(self):
256
271
        # we should not raise traceback if we try to set hidden attribute
257
272
        # on .bzr directory below unicode path
258
 
        self.requireFeature(features.UnicodeFilenameFeature)
 
273
        self.requireFeature(UnicodeFilenameFeature)
259
274
        os.makedirs(u'\u1234\\.bzr')
260
275
        path = osutils.abspath(u'\u1234\\.bzr')
261
276
        win32utils.set_file_attr_hidden(path)