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