diff --git a/runtests.py b/runtests.py index 5da5428c..735acf2e 100644 --- a/runtests.py +++ b/runtests.py @@ -1,3 +1,4 @@ +import argparse import os import sys @@ -14,13 +15,35 @@ from django.test.utils import get_runner -def runtests(): +def runtests(modules=["tinymce"], verbosity=1, failfast=False): django.setup() TestRunner = get_runner(settings) - test_runner = TestRunner(verbosity=1, interactive=True) - failures = test_runner.run_tests(["tinymce"]) + test_runner = TestRunner(interactive=True, verbosity=verbosity, failfast=failfast) + failures = test_runner.run_tests(modules) sys.exit(bool(failures)) if __name__ == "__main__": - runtests() + parser = argparse.ArgumentParser(description="Run the django-tinymce test suite.") + parser.add_argument( + "modules", + nargs="*", + metavar="module", + help='Optional path(s) to test modules; e.g. "tinymce" or ' + '"tinymce.tests.test_widgets".', + ) + parser.add_argument( + "-v", + "--verbosity", + default=1, + type=int, + choices=[0, 1, 2, 3], + help="Verbosity level; 0=minimal output, 1=normal output, 2=all output", + ) + parser.add_argument( + "--failfast", + action="store_true", + help="Stop running the test suite after first failed test.", + ) + options = parser.parse_args() + runtests(modules=options.modules, verbosity=options.verbosity, failfast=options.failfast)