Ignore:
Timestamp:
Apr 23, 2007, 4:02:34 PM (17 years ago)
Author:
duncan
Message:

checking in a set up of testing verbose sections of the code. May not be the final version.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/test_all.py

    r3678 r4414  
    1212import os
    1313import sys
     14import tempfile
    1415
    1516
     
    6566
    6667
    67 def regressionTest():
     68def regressionTest(test_verbose=False):
    6869    path = os.getcwd()
    6970    test_files, path_files = get_test_files(path)
     
    8788    moduleNames = map(filenameToModuleName, files)
    8889    modules = map(__import__, moduleNames)
    89 
    9090    # Fix up the system path
    9191    for file in path_files:
    9292        sys.path.remove(file)
    93        
    9493    load = unittest.defaultTestLoader.loadTestsFromModule
    95     return unittest.TestSuite(map(load, modules))
     94    testCaseClasses = map(load, modules)
     95    if test_verbose is True:
     96        print "moduleNames", moduleNames
     97        print "modules", modules
     98        print "load", load
     99        #print "weak", testCaseClasses.countTestCases()
     100        #sys.exit()
     101        i=0
     102        from anuga.shallow_water.test_data_manager import Test_Data_Manager
     103        from anuga.geospatial_data.test_geospatial_data import Test_Geospatial_data
     104        #print "test_data_manager.Test_Data_Manager", type(Test_Data_Manager)
     105        for test_suite in testCaseClasses:
     106            i += 1
     107            print "counting ", i
     108            #testCaseClass.classVerbose = True
     109            #testCaseClass.Verbose = True
     110            #print "testCaseClass",testCaseClass
     111            #print "testCaseClass",type(tests)
     112            #print "weak", tests.countTestCases()
     113            #print "weak", tests.__weakref__
     114            #print "dic",  tests.__dict__
     115            #print "testCaseClass.tests",  testCaseClass._tests[0]._tests[0].yah()
     116            for tests in test_suite._tests:
     117                #tests is of class TestSuite
     118                print "tests weak", tests.__weakref__
     119                if len(tests._tests) >1:
     120                    # these are the test functions
     121                    print "tests._tests[0]", tests._tests[0]
     122                    print "tests._tests[0]", tests._tests[0].__dict__
     123                    #print "tests._tests[0]", tests._tests[0].__name__
     124                    try:
     125                        # Calls set_verbose in the test case classes
     126                        tests._tests[0].set_verbose()
     127                    except:
     128                        pass # No all classes have
     129                    tests._tests[0].verbose=True # A call methods
     130                    if type(tests._tests[0]) == type(Test_Data_Manager):
     131                        print "testCaseClass is the class Test_Data_Manager"
     132                        sys.exit()
     133               
     134                    if type(tests._tests[0]) == type(Test_Geospatial_data):
     135                        print "testCaseClass is the class Test_Data_Manager"
     136                        sys.exit()
     137            if isinstance(tests, Test_Data_Manager):
     138                print "testCaseClass is an instance of Test_Data_Manager"
     139                sys.exit()
     140            if type(tests) == type(Test_Data_Manager):
     141                print "testCaseClass is the class Test_Data_Manager"
     142                sys.exit()
     143           
     144        #sys.exit()   
     145    return unittest.TestSuite(testCaseClasses)
    96146
    97147if __name__ == '__main__':
    98     #unittest.main(defaultTest='regressionTest')
    99 
    100     suite = regressionTest()
     148    if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V':
     149        test_verbose = True
     150        saveout = sys.stdout   
     151        filename = ".temp"
     152        fid = open(filename, 'w')
     153        sys.stdout = fid
     154    else:
     155        test_verbose = False       
     156    suite = regressionTest(test_verbose)
    101157    runner = unittest.TextTestRunner() #verbosity=2
    102158    runner.run(suite)
    103159   
     160    # Cleaning up
     161    if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V':
     162        sys.stdout = saveout
     163        #fid.close() # This was causing an error in windows
     164        #os.remove(filename)
     165
Note: See TracChangeset for help on using the changeset viewer.