forked from django-cms/django-cms
-
Notifications
You must be signed in to change notification settings - Fork 1
/
runtests-isolated.py
executable file
·41 lines (38 loc) · 1.51 KB
/
runtests-isolated.py
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
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
from __future__ import with_statement
import pkgutil
import pyclbr
import subprocess
import argparse
import sys
import os.path
#from iterools import ifilter
def main(argv, failfast=False, test_labels=None):
testlist = []
for module in [name for _, name, _ in pkgutil.iter_modules([os.path.join("cms","tests")])]:
clsmembers = pyclbr.readmodule("cms.tests.%s" % module)
for clsname,cls in clsmembers.items():
testlist.append(cls)
for cls in testlist:
for method, line in cls.methods.items():
if not method.startswith('test_'):
continue
test = '%s.%s' % (cls.name, method)
if not test_labels or filter(lambda x: test.find(x)>-1, test_labels):
print "Running ",test,
args = ['python', 'runtests.py'] + argv + [test]
p = subprocess.Popen(args, stdout = subprocess.PIPE, stderr= subprocess.PIPE)
output, error = p.communicate()
if p.returncode > 0:
print error
if failfast:
sys.exit(p.returncode)
else:
print
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--failfast', action='store_true', default=False,
dest='failfast')
parser.add_argument('test_labels', nargs='*')
args = parser.parse_args()
main(sys.argv[2:],failfast=args.failfast,test_labels=args.test_labels)