forked from sloria/TextBlob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
57 lines (48 loc) · 1.43 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
The main test runner script.
Usage: ::
python run_tests.py
Skip slow tests
python run_tests.py fast
When there's no Internet
python run_tests.py no-internet
'''
from __future__ import unicode_literals
import nose
import sys
from text.compat import PY2
PY26 = PY2 and int(sys.version_info[1]) < 7
def main():
args = get_argv()
success = nose.run(argv=args)
sys.exit(0) if success else sys.exit(1)
def get_argv():
args = [sys.argv[0],'--exclude', 'nltk']
attr_conditions = [] # Use nose's attribselect plugin to filter tests
if "force-all" in sys.argv:
# Don't exclude any tests
return args
if PY26:
# Exclude tests that don't work on python2.6
attr_conditions.append("not py27_only")
try:
__import__('numpy')
except ImportError:
# Exclude tests that require numpy
attr_conditions.append("not requires_numpy")
if not PY2:
# Exclude tests that only work on python2
attr_conditions.append("not py2_only")
if "fast" in sys.argv:
attr_conditions.append("not slow")
if "no-internet" in sys.argv:
# Exclude tests that require internet
attr_conditions.append("not requires_internet")
attr_expression = " and ".join(attr_conditions)
if attr_expression:
args.extend(["-A", attr_expression])
return args
if __name__ == '__main__':
main()