Changeset 3983
- Timestamp:
- Nov 14, 2006, 2:20:29 PM (18 years ago)
- Location:
- anuga_core/source/anuga/abstract_2d_finite_volumes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py
r3931 r3983 5 5 from Numeric import zeros, array, allclose, Float 6 6 from math import sqrt, pi 7 import tempfile 7 import tempfile, os 8 from os import access, F_OK,sep, removedirs 8 9 9 10 from anuga.abstract_2d_finite_volumes.util import * … … 1154 1155 assert info.startswith('Revision') 1155 1156 1156 1157 1158 def test_add_directories(self): 1159 1160 import tempfile 1161 root_dir = tempfile.mkdtemp('_test_util', 'test_util_') 1162 directories = ['ja','ne','ke'] 1163 kens_dir = add_directories(root_dir, directories) 1164 assert kens_dir == root_dir + sep + 'ja' + sep + 'ne' + \ 1165 sep + 'ke' 1166 assert access(root_dir,F_OK) 1167 1168 #clean up! 1169 os.rmdir(kens_dir) 1170 os.rmdir(root_dir + sep + 'ja' + sep + 'ne') 1171 os.rmdir(root_dir + sep + 'ja') 1172 os.rmdir(root_dir) 1157 1173 1158 1174 #------------------------------------------------------------- 1159 1175 if __name__ == "__main__": 1160 1176 suite = unittest.makeSuite(Test_Util,'test') 1161 #suite = unittest.makeSuite(Test_Util,'test_ get_version_info')1177 #suite = unittest.makeSuite(Test_Util,'test_add_directories') 1162 1178 runner = unittest.TextTestRunner() 1163 1179 runner.run(suite) -
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r3953 r3983 9 9 10 10 from os import remove, mkdir, access, F_OK, sep 11 from os.path import exists 11 from os.path import exists, basename 12 12 from warnings import warn 13 13 from shutil import copy … … 1195 1195 return texfile2, elev_output 1196 1196 1197 from os.path import basename 1198 1197 # FIXME (DSG): Add unit test, make general, not just 2 files, 1198 # but any number of files. 1199 1199 def copy_code_files(dir_name, filename1, filename2): 1200 1200 """Copies "filename1" and "filename2" to "dir_name". Very useful for … … 1209 1209 print 'Files %s and %s copied' %(filename1, filename2) 1210 1210 1211 1212 1213 1214 1211 def add_directories(root_directory, directories): 1212 """ 1213 Add the first directory in directories to root_directory. Then add the second 1214 direcotory to the first directory and so on. 1215 1216 Return the path of the final directory. 1217 1218 This is handy for specifying and creating a directory where data will go. 1219 """ 1220 dir = root_directory 1221 for new_dir in directories: 1222 dir = dir + sep + new_dir 1223 if not access(dir,F_OK): 1224 mkdir (dir) 1225 return dir 1226 1227 1228
Note: See TracChangeset
for help on using the changeset viewer.