[py-svn] r8510 - in py/dist/py/magic: . testing
arigo at codespeak.net
arigo at codespeak.net
Sun Jan 23 20:00:13 CET 2005
Author: arigo
Date: Sun Jan 23 20:00:13 2005
New Revision: 8510
Modified:
py/dist/py/magic/exprinfo.py
py/dist/py/magic/testing/test_exprinfo.py
Log:
exprinfo messed up function calls that use keyword arguments.
Modified: py/dist/py/magic/exprinfo.py
==============================================================================
--- py/dist/py/magic/exprinfo.py (original)
+++ py/dist/py/magic/exprinfo.py Sun Jan 23 20:00:13 2005
@@ -235,12 +235,21 @@
vars = {'__exprinfo_fn': node.result}
source = '__exprinfo_fn('
for a in self.args:
+ if isinstance(a, ast.Keyword):
+ keyword = a.name
+ a = a.expr
+ else:
+ keyword = None
a = Interpretable(a)
a.eval(frame)
argname = '__exprinfo_%d' % len(vars)
vars[argname] = a.result
- source += argname + ','
- explanations.append(a.explanation)
+ if keyword is None:
+ source += argname + ','
+ explanations.append(a.explanation)
+ else:
+ source += '%s=%s,' % (keyword, argname)
+ explanations.append('%s=%s' % (keyword, a.explanation))
if self.star_args:
star_args = Interpretable(self.star_args)
star_args.eval(frame)
Modified: py/dist/py/magic/testing/test_exprinfo.py
==============================================================================
--- py/dist/py/magic/testing/test_exprinfo.py (original)
+++ py/dist/py/magic/testing/test_exprinfo.py Sun Jan 23 20:00:13 2005
@@ -67,8 +67,8 @@
msg = getmsg(excinfo)
assert msg.find("must be called with A") != -1
-def global_f():
- return 42
+def global_f(u=6, v=7):
+ return u*v
def test_exprinfo_funccall():
def g():
@@ -77,6 +77,13 @@
msg = getmsg(excinfo)
assert msg == 'assert 42 == 43\n + where 42 = global_f()'
+def test_exprinfo_funccall_keywords():
+ def g():
+ assert global_f(v=11) == 67
+ excinfo = getexcinfo(AssertionError, g)
+ msg = getmsg(excinfo)
+ assert msg == 'assert 66 == 67\n + where 66 = global_f(v=11)'
+
def test_keyboard_interrupt():
# XXX this test is slightly strange because it is not
# clear that "interpret" should execute "raise" statements
More information about the pytest-commit
mailing list