##// END OF EJS Templates
Change directory to simplify test_globlist...
Takafumi Arakaki -
Show More
@@ -94,18 +94,17 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 save = os.getcwdu()
98 try:
99 os.chdir(td)
97
100
98 def getpaths(names):
101 # Create empty files
99 return [os.path.join(td, fn) for fn in names]
102 for fname in filenames:
100
103 open(os.path.join(td, fname), 'w').close()
101 # create files
102 for p in getpaths(filenames):
103 open(p, '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)))
109
108
110 assert_match(['*'], filenames)
109 assert_match(['*'], filenames)
111 assert_match(['a*'], filenames_start_with_a)
110 assert_match(['a*'], filenames_start_with_a)
@@ -115,6 +114,8 b' def test_globlist():'
115 + filenames_start_with_a
114 + filenames_start_with_a
116 + filenames_end_with_b
115 + filenames_end_with_b
117 + ['*c'])
116 + ['*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