Kaydet (Commit) c8a77d33 authored tarafından Victor Stinner's avatar Victor Stinner Kaydeden (comit) GitHub

Fix SyntaxWarning on importing test_inspect (#1512)

Fix the following warning when test_inspect.py is compiled to
test_inspect.pyc:

test_inspect.py:505: SyntaxWarning: tuple parameter unpacking has been removed in 3.x
  def spam_deref(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h):

Replace also test.test_support import with test.support.
üst 4e7457b8
...@@ -5,10 +5,11 @@ import unittest ...@@ -5,10 +5,11 @@ import unittest
import inspect import inspect
import linecache import linecache
import datetime import datetime
import textwrap
from UserList import UserList from UserList import UserList
from UserDict import UserDict from UserDict import UserDict
from test.test_support import run_unittest, check_py3k_warnings, have_unicode from test.support import run_unittest, check_py3k_warnings, have_unicode
with check_py3k_warnings( with check_py3k_warnings(
("tuple parameter unpacking has been removed", SyntaxWarning), ("tuple parameter unpacking has been removed", SyntaxWarning),
...@@ -502,10 +503,15 @@ class TestClassesAndFunctions(unittest.TestCase): ...@@ -502,10 +503,15 @@ class TestClassesAndFunctions(unittest.TestCase):
'g', 'h', (3, (4, (5,))), 'g', 'h', (3, (4, (5,))),
'(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h)') '(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h)')
def spam_deref(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h): with check_py3k_warnings(("tuple parameter unpacking has been removed",
def eggs(): SyntaxWarning),
return a + b + c + d + e + f + g + h quiet=True):
return eggs exec(textwrap.dedent('''
def spam_deref(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h):
def eggs():
return a + b + c + d + e + f + g + h
return eggs
'''))
self.assertArgSpecEquals(spam_deref, self.assertArgSpecEquals(spam_deref,
['a', 'b', 'c', 'd', ['e', ['f']]], ['a', 'b', 'c', 'd', ['e', ['f']]],
'g', 'h', (3, (4, (5,))), 'g', 'h', (3, (4, (5,))),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment