adding all of botlist, initial add
[botlist.git] / openbotlist / tests / misc / py / all_tests.py
blob0e10edee4fee87b125317b3626ac4db022b0b009
1 ##
2 ##
4 import sys
5 import junit
6 import os
7 import config as cfg
9 from java.lang import System
11 from org.springframework.context.support import FileSystemXmlApplicationContext
13 TOTAL_TESTS = 0
14 applicationContext = None
16 def walktree(dir, callback, result):
17 '''recursively descend the directory rooted at dir,
18 calling the callback function for each regular file'''
19 for f in os.listdir(dir):
20 pathname = '%s/%s' % (dir, f)
21 if os.path.isdir(pathname):
22 # It's a directory, recurse into it
23 walktree(pathname, callback, result)
24 elif os.path.isfile(pathname):
25 # It's a file, call the callback function
26 if f.endswith("py"):
27 callback(pathname, f, result)
28 else:
29 # Unknown file type, print a message
30 print 'Skipping %s' % pathname
32 def visitfile(path, file, result):
33 global TOTAL_TESTS
34 if file == "all_tests.py" or file == 'config.py' or file == 'all_tests_prod.py' or file == 'all_single_test.py':
35 return
36 print "test file: %s" % file
37 execfile(path, globals())
38 s = suite()
39 tests = s.tests()
40 while tests.hasMoreElements():
41 et = tests.nextElement()
42 result.addTest(et)
43 TOTAL_TESTS = TOTAL_TESTS + 1
45 if __name__ == '__main__':
47 # load the application context
48 print "Application Context: %s" % sys.argv[2]
50 # Load the multiple config files
51 arr = [sys.argv[2], sys.argv[3]]
53 applicationContext = FileSystemXmlApplicationContext(arr)
54 suite_result = junit.framework.TestSuite()
55 walktree(os.path.join(os.getcwd(), "py"), visitfile, suite_result)
57 junit.textui.TestRunner.run(suite_result)
58 print "Total Tests: %s" % TOTAL_TESTS
60 ## End of Script