##// END OF EJS Templates
Merge pull request #6446 from jhamrick/fix-files-writer...
Brian E. Granger -
r17845:83210573 merge
parent child Browse files
Show More
@@ -82,7 +82,7 b' class FilesWriter(WriterBase):'
82 for matching_filename in glob.glob(filename):
82 for matching_filename in glob.glob(filename):
83
83
84 # Make sure folder exists.
84 # Make sure folder exists.
85 dest = os.path.join(self.build_directory, filename)
85 dest = os.path.join(self.build_directory, matching_filename)
86 path = os.path.dirname(dest)
86 path = os.path.dirname(dest)
87 self._makedir(path)
87 self._makedir(path)
88
88
@@ -162,3 +162,42 b' class Testfiles(TestsBase):'
162 with open(dest, 'r') as f:
162 with open(dest, 'r') as f:
163 output = f.read()
163 output = f.read()
164 self.assertEqual(output, 'd')
164 self.assertEqual(output, 'd')
165
166 def test_glob(self):
167 """Can the FilesWriter handle globbed files correctly?"""
168
169 # Work in a temporary directory.
170 with self.create_temp_cwd():
171
172 # Create test files
173 os.mkdir('sub')
174 with open(os.path.join('sub', 'c'), 'w') as f:
175 f.write('e')
176 with open(os.path.join('sub', 'd'), 'w') as f:
177 f.write('e')
178
179 # Create the resoruces dictionary
180 res = {}
181
182 # Create files writer, test output
183 writer = FilesWriter()
184 writer.files = ['sub/*']
185 writer.build_directory = u'build'
186 writer.write(u'y', res, notebook_name="z")
187
188 # Check the output of the file
189 assert os.path.isdir(writer.build_directory)
190 dest = os.path.join(writer.build_directory, 'z')
191 with open(dest, 'r') as f:
192 output = f.read()
193 self.assertEqual(output, u'y')
194
195 # Check to make sure the globbed files were copied
196 path = os.path.join(writer.build_directory, 'sub')
197 assert os.path.isdir(path)
198 for filename in ['c', 'd']:
199 dest = os.path.join(path, filename)
200 assert os.path.isfile(dest)
201 with open(dest, 'r') as f:
202 output = f.read()
203 self.assertEqual(output, 'e')
General Comments 0
You need to be logged in to leave comments. Login now