From: Ben Darnell Date: Mon, 10 Sep 2012 01:55:47 +0000 (-0700) Subject: Add additional command-line arguments to tornado.testing.main X-Git-Tag: v3.0.0~272^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c0ee8d74c897c2b7ecb839650056c260b38af80;p=thirdparty%2Ftornado.git Add additional command-line arguments to tornado.testing.main --- diff --git a/tornado/testing.py b/tornado/testing.py index 966c86064..be507d38c 100644 --- a/tornado/testing.py +++ b/tornado/testing.py @@ -461,6 +461,14 @@ def main(**kwargs): "exception. This prints a stack trace but cannot interrupt " "certain operations. If false, the process is more reliably " "killed, but does not print a stack trace.")) + + # support the same options as unittest's command-line interface + define('verbose', type=bool) + define('quiet', type=bool) + define('failfast', type=bool) + define('catch', type=bool) + define('buffer', type=bool) + argv = [sys.argv[0]] + parse_command_line(sys.argv) if options.httpclient: @@ -470,6 +478,17 @@ def main(**kwargs): if not options.exception_on_interrupt: signal.signal(signal.SIGINT, signal.SIG_DFL) + if options.verbose is not None: + kwargs['verbosity'] = 2 + if options.quiet is not None: + kwargs['verbosity'] = 0 + if options.failfast is not None: + kwargs['failfast'] = True + if options.catch is not None: + kwargs['catchbreak'] = True + if options.buffer is not None: + kwargs['buffer'] = True + if __name__ == '__main__' and len(argv) == 1: print >> sys.stderr, "No tests specified" sys.exit(1) diff --git a/website/sphinx/releases/next.rst b/website/sphinx/releases/next.rst index e851a47ea..35d110acb 100644 --- a/website/sphinx/releases/next.rst +++ b/website/sphinx/releases/next.rst @@ -24,3 +24,6 @@ In progress unnecessary. * `tornado.testing.ExpectLog` can be used as a finer-grained alternative to `tornado.testing.LogTrapTestCase` +* The command-line interface to `tornado.testing.main` now supports + additional arguments from the underlying `unittest` module: + ``verbose``, ``quiet``, ``failfast``, ``catch``, ``buffer``.