summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-01-04 08:36:35 (GMT)
committerGitHub <noreply@github.com>2018-01-04 08:36:35 (GMT)
commit0cc99c8cd70d422e4b345837a907db30e9180ab9 (patch)
tree57959fceeec6bcb4b14a06bd243140dfa94e732f /Lib/test/test_grammar.py
parent811b2878dfc68dc3ecd81fb4b370c6e1f9ec69c2 (diff)
downloadcpython-0cc99c8cd70d422e4b345837a907db30e9180ab9.zip
cpython-0cc99c8cd70d422e4b345837a907db30e9180ab9.tar.gz
cpython-0cc99c8cd70d422e4b345837a907db30e9180ab9.tar.bz2
bpo-32482: Fix suspicious code in tests for syntax and grammar. (#5086)
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 9f26e9c..88c22b8 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -575,6 +575,10 @@ class GrammarTests(unittest.TestCase):
self.assertEqual(f(spam='fried', **{'eggs':'scrambled'}),
((), {'eggs':'scrambled', 'spam':'fried'}))
+ # Check ast errors in *args and *kwargs
+ check_syntax_error(self, "f(*g(1=2))")
+ check_syntax_error(self, "f(**g(1=2))")
+
# argument annotation tests
def f(x) -> list: pass
self.assertEqual(f.__annotations__, {'return': list})
@@ -616,10 +620,6 @@ class GrammarTests(unittest.TestCase):
def f(*, k=1): return closure
def f() -> int: return closure
- # Check ast errors in *args and *kwargs
- check_syntax_error(self, "f(*g(1=2))")
- check_syntax_error(self, "f(**g(1=2))")
-
# Check trailing commas are permitted in funcdef argument list
def f(a,): pass
def f(*args,): pass
@@ -1091,7 +1091,6 @@ class GrammarTests(unittest.TestCase):
try: 1/0
except EOFError: pass
except TypeError as msg: pass
- except RuntimeError as msg: pass
except: pass
else: pass
try: 1/0
@@ -1200,7 +1199,7 @@ class GrammarTests(unittest.TestCase):
d[1,2] = 3
d[1,2,3] = 4
L = list(d)
- L.sort(key=lambda x: x if isinstance(x, tuple) else ())
+ L.sort(key=lambda x: (type(x).__name__, x))
self.assertEqual(str(L), '[1, (1,), (1, 2), (1, 2, 3)]')
def test_atoms(self):