Changeset 6086 for anuga_core/source/anuga/test_all.py
- Timestamp:
- Dec 19, 2008, 10:38:08 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/test_all.py
r4978 r6086 20 20 exclude_files = [] 21 21 22 #if sys.platform != 'win32': 22 #if sys.platform != 'win32': 23 23 # exclude_files.append('test_advection.py') #Weave doesn't work on Linux 24 25 24 # Exclude test_advection on all platforms for the time being. See ticket:205 26 25 #exclude_files.append('test_advection.py') #Weave doesn't work on Linux 27 26 27 # Directories that should not be searched for test files. 28 28 29 # Directories that should not be searched for test files. 30 exclude_dirs = ['pypar_dist', #Special requirements 29 exclude_dirs = ['pypar_dist', #Special requirements 31 30 'props', 'wcprops', 'prop-base', 'text-base', '.svn', #Svn 32 31 'tmp'] 33 34 32 35 33 print "The following directories will be skipped over;" … … 38 36 print "" 39 37 38 40 39 def get_test_files(path): 41 42 43 40 try: 44 41 files = os.listdir(path) … … 53 50 path_files = [] 54 51 for file in files: 55 56 52 absolute_filename = path + os.sep + file 57 53 58 54 #sys.path.append('pmesh') 59 55 if os.path.isdir(absolute_filename): 60 sys.path.append(file) #FIXME: May cause name conflicts between pyvolution\mesh.py and pmesh\mesh.py on some systems 56 # FIXME: May cause name conflicts between pyvolution\mesh.py and 57 # pmesh\mesh.py on some systems 58 sys.path.append(file) 61 59 path_files.append(file) 62 print file + ',', 63 more_test_files, more_path_files =\ 64 get_test_files(absolute_filename) 65 60 print file + ',', 61 more_test_files, more_path_files = \ 62 get_test_files(absolute_filename) 66 63 test_files += more_test_files 67 64 path_files += more_path_files … … 70 67 else: 71 68 pass 72 69 73 70 return test_files, path_files 74 75 71 76 72 … … 83 79 84 80 files.sort() # Ensure same order on all platforms 85 81 86 82 print 87 83 print … … 89 85 print 90 86 print 'Files tested;' 91 #print_files = []92 87 for file in files: 93 #print_files += file + ' '94 88 print file + ',', 95 89 print … … 98 92 for file in exclude_files: 99 93 print 'WARNING: File '+ file + ' to be excluded from testing' 100 try: 94 try: 101 95 files.remove(file) 102 96 except ValueError, e: 103 msg = 'File "%s" was not found in test suite.\n' % file104 msg += 'Original error is "%s"\n' % e105 msg += 'Perhaps it should be removed from exclude list?' 97 msg = 'File "%s" was not found in test suite.\n' % file 98 msg += 'Original error is "%s"\n' % e 99 msg += 'Perhaps it should be removed from exclude list?' 106 100 raise Exception, msg 107 101 … … 109 103 moduleNames = map(filenameToModuleName, files) 110 104 modules = map(__import__, moduleNames) 111 105 112 106 # Fix up the system path 113 107 for file in path_files: 114 108 sys.path.remove(file) 115 109 116 110 load = unittest.defaultTestLoader.loadTestsFromModule 117 111 testCaseClasses = map(load, modules) 118 112 119 120 113 if test_verbose is True: 121 114 # Test the code by setting verbose to True. … … 128 121 # these are the test functions 129 122 try: 130 # Calls class method set_verbose in the test case classes 131 # print 'Tests', tests._tests[0] 132 # print 'Type', type(tests._tests[0]) 123 # Calls class method set_verbose in test case classes 133 124 tests._tests[0].set_verbose() 134 125 except: 135 pass # No all classes have set_verbose126 pass # No all classes have set_verbose 136 127 return unittest.TestSuite(testCaseClasses) 128 137 129 138 130 def check_anuga_import(): … … 143 135 print "Python cannot import ANUGA module." 144 136 print "Check you have followed all steps of its installation." 145 import sys; sys.exit() 137 import sys 138 sys.exit() 146 139 147 140 148 141 if __name__ == '__main__': 149 142 check_anuga_import() 143 150 144 if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V': 151 145 test_verbose = True 152 saveout = sys.stdout 146 saveout = sys.stdout 153 147 filename = ".temp" 154 148 fid = open(filename, 'w') 155 149 sys.stdout = fid 156 150 else: 157 test_verbose = False 151 test_verbose = False 158 152 suite = regressionTest(test_verbose) 159 153 runner = unittest.TextTestRunner() #verbosity=2 160 154 runner.run(suite) 161 155 162 156 # Cleaning up 163 157 if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V': 164 sys.stdout = saveout 158 sys.stdout = saveout 165 159 #fid.close() # This was causing an error in windows 166 160 #os.remove(filename)
Note: See TracChangeset
for help on using the changeset viewer.