diff 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
line wrap: on
line diff
--- a/genshi/template/tests/eval.py
+++ b/genshi/template/tests/eval.py
@@ -590,6 +590,29 @@
         suite.execute(data)
         self.assertEqual(['bardef', 'fooabc'], sorted(data['x']))
 
+    if not IS_PYTHON2:
+        def test_def_kwonlyarg(self):
+            suite = Suite("""
+def kwonly(*args, k):
+    return k
+x = kwonly(k="foo")
+""")
+            data = {}
+            suite.execute(data)
+            self.assertEqual("foo", data['x'])
+
+        def test_def_kwonlyarg_with_default(self):
+            suite = Suite("""
+def kwonly(*args, k="bar"):
+    return k
+x = kwonly(k="foo")
+y = kwonly()
+""")
+            data = {}
+            suite.execute(data)
+            self.assertEqual("foo", data['x'])
+            self.assertEqual("bar", data['y'])
+
     def test_def_nested(self):
         suite = Suite("""
 def doit():
Copyright (C) 2012-2017 Edgewall Software