From: Ben Darnell Date: Sun, 19 Jan 2014 23:58:06 +0000 (-0500) Subject: Add tornado.test.__main__ so the tests can be run with "-m tornado.test". X-Git-Tag: v4.0.0b1~141 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef72aac88b1ac5a36949e0ccd000ec249ff02b9a;p=thirdparty%2Ftornado.git Add tornado.test.__main__ so the tests can be run with "-m tornado.test". (This doesn't work on python 2.6) --- diff --git a/tornado/test/__main__.py b/tornado/test/__main__.py new file mode 100644 index 000000000..5953443b1 --- /dev/null +++ b/tornado/test/__main__.py @@ -0,0 +1,14 @@ +"""Shim to allow python -m tornado.test. + +This only works in python 2.7+. +""" +from __future__ import absolute_import, division, print_function, with_statement + +from tornado.test.runtests import all, main + +# tornado.testing.main autodiscovery relies on 'all' being present in +# the main module, so import it here even though it is not used directly. +# The following line prevents a pyflakes warning. +all = all + +main() diff --git a/tornado/test/runtests.py b/tornado/test/runtests.py index 37efc2050..7ebd6bd90 100644 --- a/tornado/test/runtests.py +++ b/tornado/test/runtests.py @@ -65,7 +65,7 @@ class TornadoTextTestRunner(unittest.TextTestRunner): self.stream.write("\n") return result -if __name__ == '__main__': +def main(): # The -W command-line option does not work in a virtualenv with # python 3 (as of virtualenv 1.7), so configure warnings # programmatically instead. @@ -127,3 +127,6 @@ if __name__ == '__main__': kwargs['warnings'] = False kwargs['testRunner'] = TornadoTextTestRunner tornado.testing.main(**kwargs) + +if __name__ == '__main__': + main()