]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Get the tests passing under Python 3.5b2
authorBen Darnell <ben@bendarnell.com>
Sat, 6 Jun 2015 19:40:21 +0000 (15:40 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 6 Jun 2015 19:40:21 +0000 (15:40 -0400)
tornado/test/web_test.py
tornado/util.py

index 96edd6c24226297451feceeca0f6ae1233a3a431..a93369c111a66a0af1e24eaecb0598eed62eb4d6 100644 (file)
@@ -1538,8 +1538,11 @@ class ClearAllCookiesTest(SimpleHandlerTestCase):
     def test_clear_all_cookies(self):
         response = self.fetch('/', headers={'Cookie': 'foo=bar; baz=xyzzy'})
         set_cookies = sorted(response.headers.get_list('Set-Cookie'))
-        self.assertTrue(set_cookies[0].startswith('baz=;'))
-        self.assertTrue(set_cookies[1].startswith('foo=;'))
+        # Python 3.5 sends 'baz="";'; older versions use 'baz=;'
+        self.assertTrue(set_cookies[0].startswith('baz=;') or
+                        set_cookies[0].startswith('baz="";'))
+        self.assertTrue(set_cookies[1].startswith('foo=;') or
+                        set_cookies[1].startswith('foo="";'))
 
 
 class PermissionError(Exception):
index 606ced197350ab6a2c6eb32e70d9e933cf6cb3de..ea4da8763310bbc54ca5f292929cd47a6e15f4bd 100644 (file)
@@ -13,7 +13,6 @@ and `.Resolver`.
 from __future__ import absolute_import, division, print_function, with_statement
 
 import array
-import inspect
 import os
 import sys
 import zlib
@@ -24,6 +23,13 @@ try:
 except NameError:
     xrange = range  # py3
 
+# inspect.getargspec() raises DeprecationWarnings in Python 3.5.
+# The two functions have compatible interfaces for the parts we need.
+try:
+    from inspect import getfullargspec as getargspec  # py3
+except ImportError:
+    from inspect import getargspec  # py2
+
 
 class ObjectDict(dict):
     """Makes a dictionary behave like an object, with attribute-style access.
@@ -284,7 +290,7 @@ class ArgReplacer(object):
     def __init__(self, func, name):
         self.name = name
         try:
-            self.arg_pos = inspect.getargspec(func).args.index(self.name)
+            self.arg_pos = getargspec(func).args.index(self.name)
         except ValueError:
             # Not a positional parameter
             self.arg_pos = None