show a short and nice traceback for funcarg lookup errors

--HG--
branch : trunk
This commit is contained in:
holger krekel
2010-02-04 16:01:02 +01:00
parent 7bd60b5abb
commit f95877a09b
4 changed files with 48 additions and 5 deletions

View File

@@ -64,7 +64,7 @@ class FuncargRequest:
_argprefix = "pytest_funcarg__"
_argname = None
class Error(LookupError):
class LookupError(LookupError):
""" error on performing funcarg request. """
def __init__(self, pyfuncitem):
@@ -170,7 +170,6 @@ class FuncargRequest:
if name not in available:
available.append(name)
fspath, lineno, msg = self._pyfuncitem.reportinfo()
line = "%s:%s" %(fspath, lineno)
msg = "funcargument %r not found for: %s" %(argname, line)
msg = "LookupError: no factory found for function argument %r" % (argname,)
msg += "\n available funcargs: %s" %(", ".join(available),)
raise self.Error(msg)
raise self.LookupError(msg)