~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_win32utils.py

  • Committer: Vincent Ladeuil
  • Date: 2011-08-12 09:49:24 UTC
  • mfrom: (6015.9.10 2.4)
  • mto: This revision was merged to the branch mainline in revision 6066.
  • Revision ID: v.ladeuil+lp@free.fr-20110812094924-knc5s0g7vs31a2f1
Merge 2.4 into trunk

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,
28
27
    TestCase,
29
28
    TestCaseInTempDir,
30
29
    TestSkipped,
31
 
    UnicodeFilenameFeature,
32
30
    )
33
31
from bzrlib.tests.features import backslashdir_feature
34
32
from bzrlib.win32utils import glob_expand, get_app_path
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') 
 
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') 
57
42
 
58
43
 
59
44
# Tests
78
63
                         'd/', 'd/d1', 'd/d2', 'd/e/', 'd/e/e1'])
79
64
 
80
65
    def build_unicode_tree(self):
81
 
        self.requireFeature(UnicodeFilenameFeature)
 
66
        self.requireFeature(features.UnicodeFilenameFeature)
82
67
        self.build_tree([u'\u1234', u'\u1234\u1234', u'\u1235/',
83
68
                         u'\u1235/\u1235'])
84
69
 
263
248
 
264
249
    def test_unicode_dir(self):
265
250
        # we should handle unicode paths without errors
266
 
        self.requireFeature(UnicodeFilenameFeature)
 
251
        self.requireFeature(features.UnicodeFilenameFeature)
267
252
        os.mkdir(u'\u1234')
268
253
        win32utils.set_file_attr_hidden(u'\u1234')
269
254
 
270
255
    def test_dot_bzr_in_unicode_dir(self):
271
256
        # we should not raise traceback if we try to set hidden attribute
272
257
        # on .bzr directory below unicode path
273
 
        self.requireFeature(UnicodeFilenameFeature)
 
258
        self.requireFeature(features.UnicodeFilenameFeature)
274
259
        os.makedirs(u'\u1234\\.bzr')
275
260
        path = osutils.abspath(u'\u1234\\.bzr')
276
261
        win32utils.set_file_attr_hidden(path)