comparison genshi/template/tests/eval.py @ 1024:a5e09a7ba12d trunk

Add support for kwonlyargs and kw_defaults attributes of AST argument nodes.
author hodgestar
date Sun, 16 Feb 2014 19:36:21 +0000
parents 2ed9827596a4
children
comparison
equal deleted inserted replaced
1023:2036193f89e7 1024:a5e09a7ba12d
588 """) 588 """)
589 data = {} 589 data = {}
590 suite.execute(data) 590 suite.execute(data)
591 self.assertEqual(['bardef', 'fooabc'], sorted(data['x'])) 591 self.assertEqual(['bardef', 'fooabc'], sorted(data['x']))
592 592
593 if not IS_PYTHON2:
594 def test_def_kwonlyarg(self):
595 suite = Suite("""
596 def kwonly(*args, k):
597 return k
598 x = kwonly(k="foo")
599 """)
600 data = {}
601 suite.execute(data)
602 self.assertEqual("foo", data['x'])
603
604 def test_def_kwonlyarg_with_default(self):
605 suite = Suite("""
606 def kwonly(*args, k="bar"):
607 return k
608 x = kwonly(k="foo")
609 y = kwonly()
610 """)
611 data = {}
612 suite.execute(data)
613 self.assertEqual("foo", data['x'])
614 self.assertEqual("bar", data['y'])
615
593 def test_def_nested(self): 616 def test_def_nested(self):
594 suite = Suite(""" 617 suite = Suite("""
595 def doit(): 618 def doit():
596 values = [] 619 values = []
597 def add(value): 620 def add(value):
Copyright (C) 2012-2017 Edgewall Software