forked from RDFLib/FuXi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
executable file
·102 lines (76 loc) · 2.69 KB
/
run_tests.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Testing with Nose
=================
This test runner uses Nose for test discovery and running. It uses the argument
spec of Nose, but with some options pre-set. To begin with, make sure you have
Nose installed, e.g.:
$ sudo easy_install nose
For daily test runs, use:
$ ./run_tests.py
If you supply attributes, the default ones defined in ``DEFAULT_ATTRS`` will be
ignored. So to run e.g. all tests marked ``slowtest`` or ``non_standard_dep``,
do:
$ ./run_tests.py -a slowtest,non_standard_dep
See <http://code.google.com/p/python-nose/> for furher details. An excellent
article is also available at <http://ivory.idyll.org/articles/nose-intro.html>.
Note that this is just a convenience script. You can use ``nosetests`` directly
if it's on $PATH, with the difference that you have to supply the options
pre-set here manually.
Coverage
========
If ``coverage.py`` is placed in $PYTHONPATH, it can be used to create coverage
information (using the built-in coverage plugin of Nose) if the default
option "--with-coverage" is supplied (which also enables some additional
coverage options).
See <http://nedbatchelder.com/code/modules/coverage.html> for details.
"""
NOSE_ARGS = [
'--where=./',
#'--with-doctest',
#'--doctest-extension=.doctest',
#'--doctest-tests',
'--with-coverage',
#'--enable-cover',
#'--enable-audit',
#'--extra-include=FuXi',
#'--source-folder=FuXi',
#'--trim-errors',
#'--with-EARL',
#'--with-xunit',
]
COVERAGE_EXTRA_ARGS = [
'--cover-package=FuXi',
'--cover-inclusive',
'--cover-html',
'--cover-html-dir=coverage',
]
DEFAULT_ATTRS = ['!known_issue']
DEFAULT_DIRS = ['test', 'lib', 'FuXi']
if __name__ == '__main__':
from sys import argv, exit
try:
import nose
except ImportError:
print("""\
Requires Nose. Try:
$ sudo easy_install nose
Exiting. """)
exit(1)
if '--with-coverage' in argv + NOSE_ARGS:
try:
import coverage
except ImportError:
print("No coverage module found, skipping code coverage.")
argv.remove('--with-coverage')
else:
NOSE_ARGS += COVERAGE_EXTRA_ARGS
if True not in [a.startswith('-a') \
or a.startswith('--attr=') for a in argv]:
argv.append('--attr=' + ','.join(DEFAULT_ATTRS))
if not [a for a in argv[1:] if not a.startswith('-')]:
argv += DEFAULT_DIRS # since nose doesn't look here by default..
finalArgs = NOSE_ARGS + argv
print("Running nose with:", " ".join(finalArgs[1:]))
nose.run_exit(argv=finalArgs)