[pypy-commit] pypy default: Fix pypy.tool.pytest.appsupport to work with new versions of pytest.

Manuel Jacob noreply at buildbot.pypy.org
Mon Jun 17 17:59:26 CEST 2013


Author: Manuel Jacob
Branch: 
Changeset: r64923:cbd32584ae93
Date: 2013-06-17 17:55 +0200
http://bitbucket.org/pypy/pypy/changeset/cbd32584ae93/

Log:	Fix pypy.tool.pytest.appsupport to work with new versions of pytest.

diff --git a/pypy/tool/pytest/appsupport.py b/pypy/tool/pytest/appsupport.py
--- a/pypy/tool/pytest/appsupport.py
+++ b/pypy/tool/pytest/appsupport.py
@@ -1,3 +1,5 @@
+from inspect import CO_VARARGS, CO_VARKEYWORDS
+
 import py
 from pypy.interpreter import gateway, pycode
 from pypy.interpreter.error import OperationError
@@ -35,8 +37,13 @@
             return None
     fullsource = property(fullsource, None, None, "Full source of AppCode")
 
-    def getargs(self):
-        return self.raw.co_varnames[:self.raw.co_argcount]
+    def getargs(self, var=False):
+        raw = self.raw
+        argcount = raw.co_argcount
+        if var:
+            argcount += raw.co_flags & CO_VARARGS
+            argcount += raw.co_flags & CO_VARKEYWORDS
+        return raw.co_varnames[:argcount]
 
 class AppFrame(py.code.Frame):
 
@@ -70,10 +77,10 @@
     def is_true(self, w_value):
         return self.space.is_true(w_value)
 
-    def getargs(self):
+    def getargs(self, var=False):
         space = self.space
         retval = []
-        for arg in self.code.getargs():
+        for arg in self.code.getargs(var):
             w_val = space.finditem(self.w_locals, space.wrap(arg))
             if w_val is None:
                 w_val = space.wrap('<no value found>')


More information about the pypy-commit mailing list