Ignore:
Timestamp:
Jan 20, 2009, 2:56:26 PM (16 years ago)
Author:
rwilson
Message:

Fixed bug in maxasc that failed test_all.py.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/lib/maxasc/test_maxasc.py

    r6213 r6218  
    22
    33from maxasc import *
     4import anuga.utilities.system_tools as aust
    45
    56import exceptions
     
    89
    910import sys
     11import os
    1012import re
     13import glob
    1114
    1215HEADER_SIZE = 6
     
    8285
    8386class 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
    8493    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')
    8597        self.failUnlessRaises(RuntimeError, MaxAsc,
    8698                              'test.out.asc',
    87                               ['test1.asc', 'test1_bad_num_lines.asc'])
     99                              [in_file, expected_file])
    88100
    89101    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')
    90105        self.failUnlessRaises(RuntimeError, MaxAsc,
    91106                              'test.out.asc',
    92                               ['test1.asc', 'test1_bad_num_lines.asc'])
     107                              [in_file, expected_file])
    93108
    94109    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')
    95113        self.failUnlessRaises(RuntimeError, MaxAsc,
    96114                              'test.out.asc',
    97                               ['test1.asc', 'test1_wrong_num_columns.asc'])
     115                              [in_file, expected_file])
    98116
    99117    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))
    102122
    103123    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))
    106128
    107129    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))
    110134
    111135    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))
    114140
    115141    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))
    120146
    121147    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))
    124152
    125153    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))
    128160
    129161    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))
    132169
    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)
     170if __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.