nice-ify --funcarg reporting, show paths instead of useless python reprs
--HG-- branch : trunk
This commit is contained in:
parent
e09e7148a3
commit
ac1eed545c
|
@ -457,6 +457,7 @@ def flatten(l):
|
||||||
from py._test.session import Session
|
from py._test.session import Session
|
||||||
class ShowFuncargSession(Session):
|
class ShowFuncargSession(Session):
|
||||||
def main(self, colitems):
|
def main(self, colitems):
|
||||||
|
self.fspath = py.path.local()
|
||||||
self.sessionstarts()
|
self.sessionstarts()
|
||||||
try:
|
try:
|
||||||
self.showargs(colitems[0])
|
self.showargs(colitems[0])
|
||||||
|
@ -479,8 +480,9 @@ class ShowFuncargSession(Session):
|
||||||
if available:
|
if available:
|
||||||
pluginname = plugin.__name__
|
pluginname = plugin.__name__
|
||||||
for name, factory in available:
|
for name, factory in available:
|
||||||
|
loc = self.getlocation(factory)
|
||||||
if verbose:
|
if verbose:
|
||||||
funcargspec = "%s -- from %s" %(name, plugin,)
|
funcargspec = "%s -- %s" %(name, loc,)
|
||||||
else:
|
else:
|
||||||
funcargspec = name
|
funcargspec = name
|
||||||
tw.line(funcargspec, green=True)
|
tw.line(funcargspec, green=True)
|
||||||
|
@ -489,6 +491,13 @@ class ShowFuncargSession(Session):
|
||||||
for line in doc.split("\n"):
|
for line in doc.split("\n"):
|
||||||
tw.line(" " + line.strip())
|
tw.line(" " + line.strip())
|
||||||
else:
|
else:
|
||||||
tw.line(" no docstring available", red=True)
|
tw.line(" %s: no docstring available" %(loc,),
|
||||||
tw.line(factory, red=True)
|
red=True)
|
||||||
tw.line(plugin, 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)
|
||||||
|
|
Loading…
Reference in New Issue