26
class _Win32Feature(Feature):
27
class _NeedsGlobExpansionFeature(Feature):
29
30
return sys.platform == 'win32'
31
32
def feature_name(self):
32
return 'Win32 platform'
33
return 'Internally performed glob expansion'
34
Win32Feature = _Win32Feature()
35
NeedsGlobExpansionFeature = _NeedsGlobExpansionFeature()
40
class TestWin32Feature(TestCase):
41
class TestNeedsGlobExpansionFeature(TestCase):
42
43
def test_available(self):
43
self.assertEqual(sys.platform == 'win32', Win32Feature.available())
44
self.assertEqual(sys.platform == 'win32',
45
NeedsGlobExpansionFeature.available())
45
47
def test_str(self):
46
self.assertTrue("platform" in str(Win32Feature))
48
self.assertTrue("performed" in str(NeedsGlobExpansionFeature))
49
51
class TestWin32UtilsGlobExpand(TestCaseInTempDir):
51
_test_needs_features = [Win32Feature]
53
_test_needs_features = [NeedsGlobExpansionFeature]
53
55
def test_empty_tree(self):
54
56
self.build_tree([])
67
69
'd/', 'd/d1', 'd/d2', 'd/e/', 'd/e/e1'])
68
70
self._run_testset([
71
[['a', 'a' ], ['a', 'a']],
73
[[u'a', u'a' ], [u'a', u'a']],
79
[['a*'], ['a', 'a1', 'a2', 'a11', 'a.1']],
80
[['?'], ['a', 'b', 'c', 'd']],
81
[['a?'], ['a1', 'a2']],
82
[['a??'], ['a11', 'a.1']],
83
[['b[1-2]'], ['b1', 'b2']],
84
[['A?'], ['a1', 'a2']],
81
[[u'a*'], [u'a', u'a1', u'a2', u'a11', u'a.1']],
82
[[u'?'], [u'a', u'b', u'c', u'd']],
83
[[u'a?'], [u'a1', u'a2']],
84
[[u'a??'], [u'a11', u'a.1']],
85
[[u'b[1-2]'], [u'b1', u'b2']],
86
[[u'A?'], [u'a1', u'a2']],
86
[['d/*'], ['d/d1', 'd/d2', 'd/e']],
87
[['d\\*'], ['d/d1', 'd/d2', 'd/e']],
88
[['?\\*'], ['c/c1', 'c/c2', 'd/d1', 'd/d2', 'd/e']],
89
[['*\\*'], ['c/c1', 'c/c2', 'd/d1', 'd/d2', 'd/e']],
90
[['*/'], ['c/', 'd/']],
91
[['*\\'], ['c/', 'd/']]])
88
[[u'd/*'], [u'd/d1', u'd/d2', u'd/e']],
89
[[u'd\\*'], [u'd/d1', u'd/d2', u'd/e']],
90
[[u'?\\*'], [u'c/c1', u'c/c2', u'd/d1', u'd/d2', u'd/e']],
91
[[u'*\\*'], [u'c/c1', u'c/c2', u'd/d1', u'd/d2', u'd/e']],
92
[[u'*/'], [u'c/', u'd/']],
93
[[u'*\\'], [u'c/', u'd/']]])
95
def test_tree_unicode(self):
94
96
"""Checks behaviour with non-ascii filenames"""
95
self.build_tree([u'�', u'�', u'�/', u'�/��'])
97
self.build_tree([u'\u1234', u'\u1234\u1234', u'\u1235/', u'\u1235/\u1235'])
96
98
self._run_testset([
102
[[u'�/��'], [u'�/��']],
100
[[u'\u1234'], [u'\u1234']],
101
[[u'\u1235'], [u'\u1235']],
103
[[u'\u1235/'], [u'\u1235/']],
104
[[u'\u1235/\u1235'], [u'\u1235/\u1235']],
105
[[u'?'], [u'�', u'�', u'�']],
106
[[u'*'], [u'�', u'�', u'�']],
107
[[u'?'], [u'\u1234', u'\u1235']],
108
[[u'*'], [u'\u1234', u'\u1234\u1234', u'\u1235']],
109
[[u'\u1234*'], [u'\u1234', u'\u1234\u1234']],
109
[[u'*/*'], [u'�/��']]])
111
[[u'\u1235/?'], [u'\u1235/\u1235']],
112
[[u'\u1235/*'], [u'\u1235/\u1235']],
113
[[u'\u1235\\?'], [u'\u1235/\u1235']],
114
[[u'\u1235\\*'], [u'\u1235/\u1235']],
115
[[u'?/'], [u'\u1235/']],
116
[[u'*/'], [u'\u1235/']],
117
[[u'?\\'], [u'\u1235/']],
118
[[u'*\\'], [u'\u1235/']],
119
[[u'?/?'], [u'\u1235/\u1235']],
120
[[u'*/*'], [u'\u1235/\u1235']],
121
[[u'?\\?'], [u'\u1235/\u1235']],
122
[[u'*\\*'], [u'\u1235/\u1235']]])
111
124
def _run_testset(self, testset):
112
125
for pattern, expected in testset: