diff --git a/.travis.yml b/.travis.yml index d6f2154a6e4..9075ee6a8ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ env: - PANDAS= - NPROC=2 - TEST_ARGS=--no-pep8 - - NOSE_ARGS="--processes=$NPROC --process-timeout=300" + - NOSE_ARGS="-j $NPROC" - PYTEST_ARGS="-ra --timeout=300 --durations=25 --cov-report= --cov=lib" # -n $NPROC - PYTHON_ARGS= - DELETE_FONT_CACHE= diff --git a/tests.py b/tests.py index d6c179ed31e..128f7a6ad5d 100755 --- a/tests.py +++ b/tests.py @@ -10,24 +10,41 @@ # these options. import sys +import argparse if __name__ == '__main__': from matplotlib import default_test_modules, test - extra_args = [] + parser = argparse.ArgumentParser(add_help=False) + parser.add_argument('--no-pep8', action='store_true', + help='Run all tests except PEP8 testing') + parser.add_argument('--pep8', action='store_true', + help='Run only PEP8 testing') + parser.add_argument('--no-network', action='store_true', + help='Run tests without network connection') + parser.add_argument('-j', type=int, + help='Shortcut for specifying number of test processes') + args, extra_args = parser.parse_known_args() - if '--no-pep8' in sys.argv: + if args.no_pep8: default_test_modules.remove('matplotlib.tests.test_coding_standards') sys.argv.remove('--no-pep8') - elif '--pep8' in sys.argv: + elif args.pep8: default_test_modules[:] = ['matplotlib.tests.test_coding_standards'] sys.argv.remove('--pep8') - if '--no-network' in sys.argv: + if args.no_network: from matplotlib.testing import disable_internet disable_internet.turn_off_internet() extra_args.extend(['-a', '!network']) sys.argv.remove('--no-network') + if args.j: + extra_args.extend([ + '--processes={}'.format(args.j), + '--process-timeout=300' + ]) + sys.argv.pop(sys.argv.index('-j') + 1) + sys.argv.remove('-j') print('Python byte-compilation optimization level: %d' % sys.flags.optimize)