File: test

package info (click to toggle)
sympy 1.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 36,784 kB
  • sloc: python: 460,598; xml: 359; makefile: 162; sh: 59; lisp: 4
file content (130 lines) | stat: -rwxr-xr-x 5,375 bytes parent folder | download
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env python

"""
Program to execute tests using the legacy SymPy test running interface.

Historically, SymPy developed and maintained its own test runner. This test
runner didn't have any external dependencies and offered a pytest-like interface
for test running. The test runner was invoked from the command line using this
script. This interface remains the preferred way for running SymPy's tests. Now
that SymPy uses pytest for test running, the call to `sympy.test` instead
invokes pytest via pytest's `main` function from within Python code.

See `sympy.test` for further documentation.

Notes
=====
- For the time being, the legacy SymPy test runner can still be invoked by
  running:
    `$ bin/test --use-sympy-runner`
  This option is, however, only to provide a fallback until the pytest-based
  runner has seen extensive real-world testing and will be removed in the
  future.
- To regenerate the `.test_durations` file, which is used by pytest-split to
  determine how to partition the tests into evenly sized groups, run:
    `$ bin/test --store-durations`

"""

from __future__ import print_function

import os
import re
import sys
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter

from get_sympy import path_hack
path_hack()

epilog = """
"options" are any of the options above.
"tests" are 0 or more glob strings of tests to run.
If no test arguments are given, all tests will be run.
"""

parser = ArgumentParser(
    epilog=epilog,
    formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument(
    '-s', '--use-sympy-runner', action='store_true', dest='use_sympy_runner',
    default=False, help='Use the SymPy test runner instead of pytest. This is '
    'for ensuring backwards compatibility is available while pytest is tested '
    'and is intended to be removed in the future.')
parser.add_argument(
    '-v', '--verbose', action='store_true', dest='verbose', default=False)
parser.add_argument(
    '--pdb', action='store_true', dest='pdb', default=False,
    help='Run post mortem pdb on each failure')
parser.add_argument(
    '--no-colors', action='store_false', dest='colors', default=True,
    help='Do not report colored [OK] and [FAIL]')
parser.add_argument(
    '--force-colors', action='store_true', dest='force_colors', default=False,
    help='Always use colors, even if the output is not to a terminal.')
parser.add_argument(
    '-k', dest='kw', metavar='KEYWORDS', action='store', nargs='*',
    help='Only run tests matching the given keyword expressions')
parser.add_argument(
    '--tb', dest='tb', metavar='TBSTYLE', default='short',
    help='Traceback verboseness (short/no)')
parser.add_argument(
    '--random', action='store_false', dest='sort', default=True,
    help='Run tests in random order instead of sorting them.')
parser.add_argument(
    '--seed', dest='seed', type=int, metavar='SEED',
    help='Use this seed for randomized tests.')
parser.add_argument(
    '-t', '--types', dest='types', action='store', default=None,
    choices=['gmpy', 'gmpy1', 'python'],
    help='Setup ground types.')
parser.add_argument(
    '-C', '--no-cache', dest='cache', action='store_false', default=True,
    help='Disable caching mechanism.')
parser.add_argument(
    '--timeout', action='store', dest='timeout', default=False, type=int,
    help='Set a timeout for the all functions, in seconds. '
        'By default there is no timeout.')
parser.add_argument(
    '--slow', action='store_true', dest='slow', default=None,
    help='Run only the slow functions.')
parser.add_argument(
    '--no-subprocess', action='store_false', dest='subprocess', default=True,
    help='Don\'t run the tests in a separate subprocess. '
         'This may prevent hash randomization from being enabled.')
parser.add_argument(
    '-E', '--enhance-asserts', action='store_true', dest='enhance_asserts',
    default=False,
    help='Rewrite assert statements to give more useful error messages.')
parser.add_argument(
    '--split', action='store', dest='split', type=str, default=None,
    help='Only run part of the tests. Should be of the form a/b, (e.g., 1/2)')
parser.add_argument(
    '--rerun', action='store', dest='rerun', default=0, type=int,
    help='Number of times to rerun the specified tests.')
parser.add_argument(
    '--parallel', action='store_true', dest='parallel', default=False,
    help='Parallelize the tests using the number of available cores.')
parser.add_argument(
    '--store-durations', action='store_true', dest='store_durations',
    default=False, help='Update the `.test_durations` file, which helps '
    'pytest-split partition tests into even-sized groups.')

options, args = parser.parse_known_args()

if not options.cache:
    os.environ['SYMPY_USE_CACHE'] = 'no'
if options.types:
    os.environ['SYMPY_GROUND_TYPES'] = options.types

import sympy

exit_code = sympy.test(*args, verbose=options.verbose, kw=options.kw,
    tb=options.tb, pdb=options.pdb, colors=options.colors,
    force_colors=options.force_colors, sort=options.sort,
    seed=options.seed, slow=options.slow, timeout=options.timeout,
    subprocess=options.subprocess, enhance_asserts=options.enhance_asserts,
    split=options.split, rerun=options.rerun, parallel=options.parallel,
    store_durations=options.store_durations,
    use_sympy_runner=options.use_sympy_runner)

sys.exit(exit_code)