]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Make tornado.testing.main with no arguments work in python 3.2
authorBen Darnell <ben@bendarnell.com>
Sun, 29 May 2011 21:02:27 +0000 (14:02 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 29 May 2011 21:02:27 +0000 (14:02 -0700)
tornado/testing.py

index 1b6ee9af0260e5645575beb2c7869bdb0a4f7b9e..fa91139643c6abbc63ab435df90540ed6270ba42 100644 (file)
@@ -342,9 +342,14 @@ def main():
     try:
         # In order to be able to run tests by their fully-qualified name
         # on the command line without importing all tests here,
-        # module must be set to None (in which case the defaultTest must
-        # also be fully-qualified
-        unittest.main(module=None, defaultTest='__main__.all', argv=argv)
+        # module must be set to None.  Python 3.2's unittest.main ignores
+        # defaultTest if no module is given (it tries to do its own
+        # test discovery, which is incompatible with auto2to3), so don't
+        # set module if we're not asking for a specific test.
+        if len(argv) > 1:
+            unittest.main(module=None, argv=argv)
+        else:
+            unittest.main(defaultTest="all", argv=argv)
     except SystemExit, e:
         if e.code == 0:
             logging.info('PASS')