This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
/
runtests.py
executable file
·66 lines (56 loc) · 2 KB
/
runtests.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
'''Stdnet asynchronous test suite. Requires pulsar or nose
'''
import sys
import os
## This is for dev environment with pulsar and dynts.
## If not available, some tests won't run
from stdnet.utils import Path
p = Path(__file__)
p.add2python('pulsar', up=1, down=('pulsar',), must_exist=False)
p.add2python('dynts', up=1, down=('dynts',), must_exist=False)
from stdnet.conf import settings
from stdnet import test, getdb
from stdnet.test import nose, pulsar
def noseoption(argv,*vals,**kwargs):
if vals:
for val in vals:
if val in argv:
return
argv.append(vals[0])
value = kwargs.get('value')
if value is not None:
argv.append(value)
def start():
global pulsar
argv = sys.argv
if len(argv) > 1 and argv[1] == 'nose':
pulsar = None
sys.argv.pop(1)
if pulsar:
from pulsar.apps.test import TestSuite
from pulsar.apps.test.plugins import bench, profile
os.environ['stdnet_test_suite'] = 'pulsar'
suite = TestSuite(
description = 'Stdnet Asynchronous test suite',
modules = ('tests',),
plugins = (test.PulsarStdnetServer(),
test.PulsarDataSizePlugin(),
test.PulsarRedisParser(),
bench.BenchMark(),
profile.Profile())
)
suite.start()
elif nose:
from stdnet.test import NoseDataSizePlugin, NoseStdnetServer
os.environ['stdnet_test_suite'] = 'nose'
argv = list(sys.argv)
noseoption(argv, '-w', value = 'tests/regression')
noseoption(argv, '--all-modules')
nose.main(argv=argv, addplugins=[NoseStdnetServer(),
NoseDataSizePlugin()])
else:
print('To run tests you need either pulsar or nose.')
exit(0)
if __name__ == '__main__':
start()