forked from sympy/sympy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
doctest
executable file
·59 lines (47 loc) · 1.96 KB
/
doctest
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
#!/usr/bin/env python
"""
Program to execute doctests using the py.test like interface.
The advantage over py.test is that it only depends on sympy and should just
work in any circumstances. See "sympy.dotest?" for documentation.
"""
# files listed here can be in unix forward slash format with paths
# listed relative to sympy (which contains bin, etc...)
blacklist = []
import sys
import os
from optparse import OptionParser
from get_sympy import path_hack
path_hack()
parser = OptionParser()
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
default=False)
# if you don't see a -n `default=False`;
# if you do see a -n `store_true` means to store a True value for it;
# dest is where in options to put it, options.normal will hold the bool;
# when the user enters -h or --help, print the `help` text
parser.add_option("-n", "--normal", action="store_true", dest="normal",
help="run normal doctests; do not require explicit imports", default=False)
parser.add_option('-t', '--types', dest='types', action='store',
default=None, choices=['gmpy', 'python', 'sympy'],
help='setup ground types: gmpy | python | sympy')
parser.add_option('-C', '--no-cache', dest='cache', action='store_false',
default=True, help='disable caching mechanism')
parser.set_usage("test [options ...] [files ...]")
parser.epilog = """\
"options" are any of the options above. "files" are 0 or more glob strings of \
files to run doctests on. If no file arguments are given, all doctests will be \
run. This program runs both doctests in the source and doctests in the Sphinx \
documentation (doc/src/ directory).\
"""
options, args = parser.parse_args()
if not options.cache:
os.environ['SYMPY_USE_CACHE'] = 'no'
if options.types:
os.environ['SYMPY_GROUND_TYPES'] = options.types
import sympy
ok = sympy.doctest(*args, **{"verbose": options.verbose,
"blacklist": blacklist, "normal": options.normal})
if ok:
sys.exit(0)
else:
sys.exit(1)