]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add tornado.test.__main__ so the tests can be run with "-m tornado.test".
authorBen Darnell <ben@bendarnell.com>
Sun, 19 Jan 2014 23:58:06 +0000 (18:58 -0500)
committerBen Darnell <ben@bendarnell.com>
Sun, 19 Jan 2014 23:58:06 +0000 (18:58 -0500)
(This doesn't work on python 2.6)

tornado/test/__main__.py [new file with mode: 0644]
tornado/test/runtests.py

diff --git a/tornado/test/__main__.py b/tornado/test/__main__.py
new file mode 100644 (file)
index 0000000..5953443
--- /dev/null
@@ -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()
index 37efc20505b0a98a72e027e8d62e1de5e9d1c41e..7ebd6bd90dc91bf1637f51bdbb7761fa7021359e 100644 (file)
@@ -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()