##// END OF EJS Templates
Change directory to simplify test_globlist...
Takafumi Arakaki -
Show More
@@ -94,27 +94,28 b' def test_globlist():'
94 94 filenames = filenames_start_with_a + filenames_end_with_b
95 95
96 96 with TemporaryDirectory() as td:
97
98 def getpaths(names):
99 return [os.path.join(td, fn) for fn in names]
100
101 # create files
102 for p in getpaths(filenames):
103 open(p, 'w').close()
104
105 def assert_match(patterns, matches):
106 # glob returns unordered list. that's why sorted is required.
107 nt.assert_equals(sorted(globlist(getpaths(patterns))),
108 sorted(getpaths(matches)))
109
110 assert_match(['*'], filenames)
111 assert_match(['a*'], filenames_start_with_a)
112 assert_match(['*c'], ['*c'])
113 assert_match(['*', 'a*', '*b', '*c'],
114 filenames
115 + filenames_start_with_a
116 + filenames_end_with_b
117 + ['*c'])
97 save = os.getcwdu()
98 try:
99 os.chdir(td)
100
101 # Create empty files
102 for fname in filenames:
103 open(os.path.join(td, fname), 'w').close()
104
105 def assert_match(patterns, matches):
106 # glob returns unordered list. that's why sorted is required.
107 nt.assert_equals(sorted(globlist(patterns)), sorted(matches))
108
109 assert_match(['*'], filenames)
110 assert_match(['a*'], filenames_start_with_a)
111 assert_match(['*c'], ['*c'])
112 assert_match(['*', 'a*', '*b', '*c'],
113 filenames
114 + filenames_start_with_a
115 + filenames_end_with_b
116 + ['*c'])
117 finally:
118 os.chdir(save)
118 119
119 120
120 121 @dec.skip_without('sqlite3')
General Comments 0
You need to be logged in to leave comments. Login now