| commit 1637: | 480938f9813a |
| parent 1636: | 8ad566a440d0 |
| branch: | trunk |
nice-ify --funcarg reporting, show paths instead of useless python reprs
hpk
6 weeks ago
6 weeks ago
Changed (Δ300 bytes):
raw changeset »
py/_plugin/pytest_terminal.py (13 lines added, 4 lines removed)
Up to file-list py/_plugin/pytest_terminal.py:
| … | … | @@ -457,6 +457,7 @@ def flatten(l): |
457 |
457 |
from py._test.session import Session |
458 |
458 |
class ShowFuncargSession(Session): |
459 |
459 |
def main(self, colitems): |
460 |
self.fspath = py.path.local() |
|
460 |
461 |
self.sessionstarts() |
461 |
462 |
try: |
462 |
463 |
self.showargs(colitems[0]) |
| … | … | @@ -479,8 +480,9 @@ class ShowFuncargSession(Session): |
479 |
480 |
if available: |
480 |
481 |
pluginname = plugin.__name__ |
481 |
482 |
for name, factory in available: |
483 |
loc = self.getlocation(factory) |
|
482 |
484 |
if verbose: |
483 |
funcargspec = "%s -- |
|
485 |
funcargspec = "%s -- %s" %(name, loc,) |
|
484 |
486 |
else: |
485 |
487 |
funcargspec = name |
486 |
488 |
tw.line(funcargspec, green=True) |
| … | … | @@ -489,6 +491,13 @@ class ShowFuncargSession(Session): |
489 |
491 |
for line in doc.split("\n"): |
490 |
492 |
tw.line(" " + line.strip()) |
491 |
493 |
else: |
492 |
tw.line(" no docstring available", red=True) |
|
493 |
tw.line(factory, red=True) |
|
494 |
tw.line( |
|
494 |
tw.line(" %s: no docstring available" %(loc,), |
|
495 |
red=True) |
|
496 |
||
497 |
def getlocation(self, function): |
|
498 |
import inspect |
|
499 |
fn = py.path.local(inspect.getfile(function)) |
|
500 |
lineno = function.func_code.co_firstlineno |
|
501 |
if fn.relto(self.fspath): |
|
502 |
fn = fn.relto(self.fspath) |
|
503 |
return "%s:%d" %(fn, lineno+1) |
