Improve item.warn handling of fslocation parameter
Just pass fslocation forward and let the hook implementer decide what to do with the parameter
This commit is contained in:
parent
d9a2e70155
commit
cac82e71d8
|
@ -309,9 +309,6 @@ class Node(object):
|
|||
fslocation = getattr(self, "location", None)
|
||||
if fslocation is None:
|
||||
fslocation = getattr(self, "fspath", None)
|
||||
else:
|
||||
fslocation = "%s:%s" % (fslocation[0], fslocation[1] + 1)
|
||||
|
||||
self.ihook.pytest_logwarning.call_historic(kwargs=dict(
|
||||
code=code, message=message,
|
||||
nodeid=self.nodeid, fslocation=fslocation))
|
||||
|
|
|
@ -109,10 +109,10 @@ class WarningReport(object):
|
|||
if self.nodeid:
|
||||
return self.nodeid
|
||||
if self.fslocation:
|
||||
if isinstance(self.fslocation, tuple) and len(self.fslocation) == 2:
|
||||
filename, linenum = self.fslocation
|
||||
if isinstance(self.fslocation, tuple) and len(self.fslocation) >= 2:
|
||||
filename, linenum = self.fslocation[:2]
|
||||
relpath = py.path.local(filename).relto(config.invocation_dir)
|
||||
return '%s:%d' % (relpath, linenum)
|
||||
return '%s:%s' % (relpath, linenum)
|
||||
else:
|
||||
return str(self.fslocation)
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue