Kaydet (Commit) 52cc9a97 authored tarafından Batuhan Taşkaya's avatar Batuhan Taşkaya

invalid tests

üst 96d700ca
......@@ -240,15 +240,15 @@ class SourceGenerator(ExplicitNodeVisitor):
self.write(write_comma, arg)
self.conditional_write('=', default)
posonlyargs = getattr(node, "posonlyargs", [])
posonlyargs = getattr(node, 'posonlyargs', [])
offset = 0
if posonlyargs:
offset += len(node.defaults) - len(node.args)
loop_args(posonlyargs, node.defaults[:offset])
self.write(write_comma, "/")
self.write(write_comma, '/')
loop_args(node.args, node.defaults[offset:])
self.conditional_write(write_comma, "*", node.vararg)
self.conditional_write(write_comma, '*', node.vararg)
kwonlyargs = self.get_kwonlyargs(node)
if kwonlyargs:
......
......@@ -180,6 +180,19 @@ class CodegenTestCase(unittest.TestCase, Comparisons):
pass
"""
self.assertSrcRoundtrips(source)
with self.assertRaises(SyntaxError):
invalid_source = """
def test(p1, p2=None, /, p_or_kw, *, kw):
pass
def test(p1=None, p2, /, p_or_kw=None, *, kw):
pass
def test(p1=None, p2, /):
pass
"""
self.assertSrcRoundtrips(invalid_source)
def test_pass_arguments_node(self):
source = canonical("""
......
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