]> rtime.felk.cvut.cz Git - wvtest.git/blob - python/wvtestmain.py
Added an initial README.
[wvtest.git] / python / wvtestmain.py
1 #!/usr/bin/python
2 #
3 # WvTest:
4 #   Copyright (C)2009 EQL Data Inc. and contributors.
5 #       Licensed under the GNU Library General Public License, version 2.
6 #       See the included file named LICENSE for license information.
7 #
8 import wvtest
9 import sys, imp, types, os, os.path
10 import traceback
11
12 def runtest(modname, fname, f):
13     print
14     print 'Testing "%s" in %s.py:' % (fname, modname)
15     try:
16         f()
17     except Exception, e:
18         print
19         print traceback.format_exc()
20         tb = sys.exc_info()[2]
21         wvtest._result(e, traceback.extract_tb(tb)[-1],
22                        'EXCEPTION')
23
24 for modname in sys.argv[1:]:
25     if modname.endswith('.py'):
26         modname = modname[:-3]
27     print
28     print 'Importing: %s' % modname
29     wvtest._registered = []
30     mod = __import__(modname, None, None, [])
31
32     for t in wvtest._registered:
33         runtest(modname, t.func_name, t)
34                         
35 print
36 print 'WvTest: %d tests, %d failures.' % (wvtest._tests, wvtest._fails)