FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-32482: Fix suspicious code in tests for syntax and grammar. by serhiy-storchaka · Pull Request #5086 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 5 additions & 6 deletions Lib/test/test_grammar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,10 @@ def f(*args, **kwargs):
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})
Expand Down Expand Up @@ -616,10 +620,6 @@ def f(x=1): return closure
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
Expand Down Expand Up @@ -1017,7 +1017,6 @@ def test_try(self):
try: 1/0
except EOFError: pass
except TypeError as msg: pass
except RuntimeError as msg: pass
except: pass
else: pass
try: 1/0
Expand Down Expand Up @@ -1126,7 +1125,7 @@ def test_selectors(self):
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):
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_syntax.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -668,12 +668,12 @@ def test_kwargs_last(self):
"positional argument follows keyword argument")

def test_kwargs_last2(self):
self._check_error("int(**{base: 10}, '2')",
self._check_error("int(**{'base': 10}, '2')",
"positional argument follows "
"keyword argument unpacking")

def test_kwargs_last3(self):
self._check_error("int(**{base: 10}, *['2'])",
self._check_error("int(**{'base': 10}, *['2'])",
"iterable argument unpacking follows "
"keyword argument unpacking")

Expand Down

Back | FazBrowse Home | New Git URL