File: run_all_tests.py

package info (click to toggle)
kiwi 1.9.22-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 11,912 kB
  • ctags: 5,549
  • sloc: python: 15,779; ansic: 193; xml: 77; makefile: 57; sh: 18
file content (31 lines) | stat: -rw-r--r-- 894 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
import os
import glob
import sys
import inspect
import unittest

myself = os.path.abspath(__file__)
testdir =  os.path.dirname(myself)
if testdir not in sys.path:
    sys.path.append(testdir)
sys.path.insert(0, os.path.join(testdir, '..'))

print 'Running tests on', testdir

from kiwi.environ import require_gazpacho
require_gazpacho()
suite = unittest.TestSuite()

for file in glob.glob(os.path.join(testdir, 'test_*.py')):
    filename = os.path.basename(file)
    modulename = os.path.splitext(filename)[0]
    mod = __import__(modulename, globals(), locals())
    members = [mem[1] for mem in inspect.getmembers(mod, inspect.isclass) \
               if issubclass(mem[1], unittest.TestCase) \
               and not mem[1] == unittest.TestCase]
    for mem in members:
        suite.addTest(unittest.makeSuite(mem))


unittest.TextTestRunner(verbosity=2).run(suite)