[py-svn] py-trunk commit 480938f9813a: nice-ify --funcarg reporting, show paths instead of useless python reprs

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sun Feb 7 02:09:23 CET 2010


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1265504954 -3600
# Node ID 480938f9813a5ac7c1d96c779a02595d2ee14635
# Parent 8ad566a440d003e40eca621c5adb796ad5973c03
nice-ify --funcarg reporting, show paths instead of useless python reprs

--- a/py/_plugin/pytest_terminal.py
+++ b/py/_plugin/pytest_terminal.py
@@ -457,6 +457,7 @@ def flatten(l):
 from py._test.session import Session
 class ShowFuncargSession(Session):
     def main(self, colitems):
+        self.fspath = py.path.local()
         self.sessionstarts()
         try:
             self.showargs(colitems[0])
@@ -479,8 +480,9 @@ class ShowFuncargSession(Session):
             if available:
                 pluginname = plugin.__name__
                 for name, factory in available:
+                    loc = self.getlocation(factory)
                     if verbose:
-                        funcargspec = "%s -- from %s" %(name, plugin,)
+                        funcargspec = "%s -- %s" %(name, loc,)
                     else:
                         funcargspec = name
                     tw.line(funcargspec, green=True)
@@ -489,6 +491,13 @@ class ShowFuncargSession(Session):
                         for line in doc.split("\n"):
                             tw.line("    " + line.strip())
                     else:
-                        tw.line("    no docstring available", red=True)
-                        tw.line(factory, red=True)
-                        tw.line(plugin, red=True)
+                        tw.line("    %s: no docstring available" %(loc,), 
+                            red=True)
+
+    def getlocation(self, function):
+        import inspect
+        fn = py.path.local(inspect.getfile(function))
+        lineno = function.func_code.co_firstlineno
+        if fn.relto(self.fspath):
+            fn = fn.relto(self.fspath)
+        return "%s:%d" %(fn, lineno+1)



More information about the pytest-commit mailing list