Changeset 5072
- Timestamp:
- Feb 26, 2008, 9:06:19 AM (17 years ago)
- Location:
- anuga_core/source/anuga/utilities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/system_tools.py
r5048 r5072 203 203 204 204 return crcval 205 206 def get_pathname_from_package(package): 207 """Get pathname of given package (provided as string) 208 209 This is useful for reading files residing in the same directory as 210 a particular module. Typically, this is required in unit tests depending 211 on external files. 212 213 The given module must start from a directory on the pythonpath 214 and be importable using the import statement. 215 216 Example 217 path = get_pathname_from_package('anuga.utilities') 218 219 """ 220 221 exec('import %s as x' %package) 222 223 path = x.__path__[0] 224 225 return path 226 227 # Alternative approach that has been used at times 228 #try: 229 # # When unit test is run from current dir 230 # p1 = read_polygon('mainland_only.csv') 231 #except: 232 # # When unit test is run from ANUGA root dir 233 # from os.path import join, split 234 # dir, tail = split(__file__) 235 # path = join(dir, 'mainland_only.csv') 236 # p1 = read_polygon(path) 237 238 239 240 -
anuga_core/source/anuga/utilities/test_polygon.py
r5050 r5072 6 6 from math import sqrt, pi 7 7 from anuga.utilities.numerical_tools import ensure_numeric 8 from anuga.utilities.system_tools import get_pathname_from_package 8 9 9 10 from polygon import * … … 60 61 from os import sep, getenv 61 62 62 63 try: 64 # When unit test is run from current dir 65 p1 = read_polygon('mainland_only.csv') 66 except: 67 # When unit test is run from ANUGA root dir 68 from os.path import join, split 69 dir, tail = split( __file__) 70 path = join(dir, 'mainland_only.csv') 71 p1 = read_polygon(path) 72 73 63 64 # Get path where this test is run 65 path = get_pathname_from_package('anuga.utilities') 66 67 # Form absolute filename and read 68 filename = path + sep + 'mainland_only.csv' 69 p1 = read_polygon(filename) 70 74 71 75 72 f = Polygon_function( [(p1, 10.0)] ) -
anuga_core/source/anuga/utilities/test_system_tools.py
r5048 r5072 109 109 110 110 # Get path where this test is run 111 import anuga.utilities as u112 path = u.__path__[0]111 path = get_pathname_from_package('anuga.utilities') 112 113 113 filename = path + sep + 'crc_test_file.png' 114 114
Note: See TracChangeset
for help on using the changeset viewer.