Changeset 6218 for anuga_core/source/anuga/lib/maxasc
- Timestamp:
- Jan 20, 2009, 2:56:26 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/lib/maxasc/test_maxasc.py
r6213 r6218 2 2 3 3 from maxasc import * 4 import anuga.utilities.system_tools as aust 4 5 5 6 import exceptions … … 8 9 9 10 import sys 11 import os 10 12 import re 13 import glob 11 14 12 15 HEADER_SIZE = 6 … … 82 85 83 86 class Test_MaxAsc(unittest.TestCase): 87 def tearDown(self): 88 # delete all output files 89 files = glob.glob('*.out.asc') 90 for file in files: 91 os.remove(file) 92 84 93 def test_unequal_lines(self): 94 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 95 in_file = os.path.join(test_path, 'test1.asc') 96 expected_file = os.path.join(test_path, 'test1_bad_num_lines.asc') 85 97 self.failUnlessRaises(RuntimeError, MaxAsc, 86 98 'test.out.asc', 87 [ 'test1.asc', 'test1_bad_num_lines.asc'])99 [in_file, expected_file]) 88 100 89 101 def test_headers_differ(self): 102 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 103 in_file = os.path.join(test_path, 'test1.asc') 104 expected_file = os.path.join(test_path, 'test1_bad_num_lines.asc') 90 105 self.failUnlessRaises(RuntimeError, MaxAsc, 91 106 'test.out.asc', 92 [ 'test1.asc', 'test1_bad_num_lines.asc'])107 [in_file, expected_file]) 93 108 94 109 def test_wrong_num_columns(self): 110 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 111 in_file = os.path.join(test_path, 'test1.asc') 112 expected_file = os.path.join(test_path, 'test1_wrong_num_columns.asc') 95 113 self.failUnlessRaises(RuntimeError, MaxAsc, 96 114 'test.out.asc', 97 [ 'test1.asc', 'test1_wrong_num_columns.asc'])115 [in_file, expected_file]) 98 116 99 117 def test_same_input_equals_output1(self): 100 MaxAsc('test1.out.asc', ['test1.asc']) 101 self.failUnless(FilesEqual('test1.out.asc', 'test1.asc')) 118 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 119 in_file = os.path.join(test_path, 'test1.asc') 120 MaxAsc('test1.out.asc', [in_file]) 121 self.failUnless(FilesEqual('test1.out.asc', in_file)) 102 122 103 123 def test_same_input_equals_bigA(self): 104 MaxAsc('perth.out.asc', ['perthAll_stage_250m.asc']) 105 self.failUnless(FilesEqual('perth.out.asc', 'perthAll_stage_250m.asc')) 124 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 125 in_file = os.path.join(test_path, 'perthAll_stage_250m.asc') 126 MaxAsc('perth.out.asc', [in_file]) 127 self.failUnless(FilesEqual('perth.out.asc', in_file)) 106 128 107 129 def test_same_input_equals_bigB(self): 108 MaxAsc('perth.out.asc', ['perthAll_stage_250m_all.asc']) 109 self.failUnless(FilesEqual('perth.out.asc', 'perthAll_stage_250m_all.asc')) 130 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 131 in_file = os.path.join(test_path, 'perthAll_stage_250m_all.asc') 132 MaxAsc('perth.out.asc', [in_file]) 133 self.failUnless(FilesEqual('perth.out.asc', in_file)) 110 134 111 135 def test_same_input_equals_bigC(self): 112 MaxAsc('perth.out.asc', ['perthAll_stage_original.asc']) 113 self.failUnless(FilesEqual('perth.out.asc', 'perthAll_stage_original.asc')) 136 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 137 in_file = os.path.join(test_path, 'perthAll_stage_original.asc') 138 MaxAsc('perth.out.asc', [in_file]) 139 self.failUnless(FilesEqual('perth.out.asc', in_file)) 114 140 115 141 def test_same_input_equals_big3(self): 116 MaxAsc('perth.out.asc', ['perthAll_stage_250m.asc',117 'perthAll_stage_250m.asc',118 'perthAll_stage_250m.asc'])119 self.failUnless(FilesEqual('perth.out.asc', 'perthAll_stage_250m.asc'))142 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 143 in_file = os.path.join(test_path, 'perthAll_stage_250m.asc') 144 MaxAsc('perth.out.asc', [in_file, in_file, in_file]) 145 self.failUnless(FilesEqual('perth.out.asc', in_file)) 120 146 121 147 def test_same_input_equals_outputN(self): 122 MaxAsc('test1.out.asc', ['test1.asc'] * 30) 123 self.failUnless(FilesEqual('test1.out.asc', 'test1.asc')) 148 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 149 in_file = os.path.join(test_path, 'test1.asc') 150 MaxAsc('test1.out.asc', [in_file] * 30) 151 self.failUnless(FilesEqual('test1.out.asc', in_file)) 124 152 125 153 def test_different_input2(self): 126 MaxAsc('test2.out.asc', ['test1.asc', 'test2.asc']) 127 self.failUnless(FilesEqual('test2.out.asc', 'test2.expected.asc')) 154 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 155 in_file = os.path.join(test_path, 'test1.asc') 156 in_file2 = os.path.join(test_path, 'test2.asc') 157 expected_file = os.path.join(test_path, 'test2.expected.asc') 158 MaxAsc('test2.out.asc', [in_file, in_file2]) 159 self.failUnless(FilesEqual('test2.out.asc', expected_file)) 128 160 129 161 def test_different_input3(self): 130 MaxAsc('test3.out.asc', ['test1.asc', 'test2.asc', 'test3.asc']) 131 self.failUnless(FilesEqual('test3.out.asc', 'test3.expected.asc')) 162 test_path = aust.get_pathname_from_package('anuga.lib.maxasc') 163 in_file = os.path.join(test_path, 'test1.asc') 164 in_file2 = os.path.join(test_path, 'test2.asc') 165 in_file3 = os.path.join(test_path, 'test3.asc') 166 expected_file = os.path.join(test_path, 'test3.expected.asc') 167 MaxAsc('test3.out.asc', [in_file, in_file2, in_file3]) 168 self.failUnless(FilesEqual('test3.out.asc', expected_file)) 132 169 133 134 suite = unittest.makeSuite(Test_MaxAsc,'test') 135 #suite = unittest.makeSuite(Test_MaxAsc,'test_same_input_equals_output1') 136 runner = unittest.TextTestRunner(verbosity=1) 137 runner.run(suite) 170 if __name__ == '__main__': 171 suite = unittest.makeSuite(Test_MaxAsc,'test') 172 runner = unittest.TextTestRunner(verbosity=1) 173 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.