[py-svn] py-trunk commit f29d1d8a6384: fix keyword calling

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Nov 27 20:46:39 CET 2009


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1259350341 -3600
# Node ID f29d1d8a63849e6d6fcb70593c671ed07f69842b
# Parent 1ee4a66511d2eb065198a9a3a7d2f23e0cf6c218
fix keyword calling

--- a/testing/code/test_assertion.py
+++ b/testing/code/test_assertion.py
@@ -93,6 +93,14 @@ def test_assert_non_string_message():
         e = exvalue()
         assert e.msg == "hello"
 
+def test_assert_keyword_arg():
+    def f(x=3):
+        return False
+    try:
+        assert f(x=5)
+    except AssertionError:
+        e = exvalue()
+        assert "x=5" in e.msg
 
 # These tests should both fail, but should fail nicely...
 class WeirdRepr:

--- a/py/impl/code/_assertionnew.py
+++ b/py/impl/code/_assertionnew.py
@@ -234,7 +234,7 @@ class DebugInterpreter(ast.NodeVisitor):
             arg_explanation, arg_result = self.visit(keyword.value)
             arg_name = "__exprinfo_%s" % (len(ns),)
             ns[arg_name] = arg_result
-            keyword_source = "%s=%%s" % (keyword.id)
+            keyword_source = "%s=%%s" % (keyword.arg)
             arguments.append(keyword_source % (arg_name,))
             arg_explanations.append(keyword_source % (arg_explanation,))
         if call.starargs:

--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+Changes between 1.1.2 and 1.1.1
+=====================================
+
+- fix assert reinterpreation that sees a call containing "keyword=..."
+
 Changes between 1.1.1 and 1.1.0
 =====================================



More information about the pytest-commit mailing list