|
10 | 10 | # these options.
|
11 | 11 |
|
12 | 12 | import sys
|
| 13 | +import argparse |
13 | 14 |
|
14 | 15 |
|
15 | 16 | if __name__ == '__main__':
|
16 | 17 | from matplotlib import default_test_modules, test
|
17 | 18 |
|
18 |
| - extra_args = [] |
| 19 | + parser = argparse.ArgumentParser(add_help=False) |
| 20 | + parser.add_argument('--no-pep8', action='store_true', |
| 21 | + help='Run all tests except PEP8 testing') |
| 22 | + parser.add_argument('--pep8', action='store_true', |
| 23 | + help='Run only PEP8 testing') |
| 24 | + parser.add_argument('--no-network', action='store_true', |
| 25 | + help='Run tests without network connection') |
| 26 | + parser.add_argument('-j', type=int, |
| 27 | + help='Shortcut for specifying number of test processes') |
| 28 | + args, extra_args = parser.parse_known_args() |
19 | 29 |
|
20 |
| - if '--no-pep8' in sys.argv: |
| 30 | + if args.no_pep8: |
21 | 31 | default_test_modules.remove('matplotlib.tests.test_coding_standards')
|
22
32 | sys.argv.remove('--no-pep8')
|
23 |
| - elif '--pep8' in sys.argv: |
| 33 | + elif args.pep8: |
24 | 34 | default_test_modules[:] = ['matplotlib.tests.test_coding_standards']
|
25 | 35 | sys.argv.remove('--pep8')
|
26 |
| - if '--no-network' in sys.argv: |
| 36 | + if args.no_network: |
27 | 37 | from matplotlib.testing import disable_internet
|
28 | 38 | disable_internet.turn_off_internet()
|
29 | 39 | extra_args.extend(['-a', '!network'])
|
30 | 40 | sys.argv.remove('--no-network')
|
| 41 | + if args.j: |
| 42 | + extra_args.extend([ |
| 43 | + '--processes={}'.format(args.j), |
| 44 | + '--process-timeout=300' |
| 45 | + ]) |
| 46 | + sys.argv.pop(sys.argv.index('-j') + 1) |
| 47 | + sys.argv.remove('-j') |
31 | 48 |
|
32 | 49 | print('Python byte-compilation optimization level: %d' % sys.flags.optimize)
|
33 | 50 |
|
|
0 commit comments