Fix line offsets with `ScopeMismatch` errors
Fixes https://github.com/pytest-dev/pytest/issues/4928.
This commit is contained in:
parent
158432217c
commit
d441fa66fe
|
@ -0,0 +1 @@
|
|||
Fix line offsets with ``ScopeMismatch`` errors.
|
|
@ -612,7 +612,7 @@ class FixtureRequest(FuncargnamesCompatAttr):
|
|||
fs, lineno = getfslineno(factory)
|
||||
p = self._pyfuncitem.session.fspath.bestrelpath(fs)
|
||||
args = _format_args(factory)
|
||||
lines.append("%s:%d: def %s%s" % (p, lineno, factory.__name__, args))
|
||||
lines.append("%s:%d: def %s%s" % (p, lineno + 1, factory.__name__, args))
|
||||
return lines
|
||||
|
||||
def _getscopeitem(self, scope):
|
||||
|
|
|
@ -992,8 +992,8 @@ class TestFixtureUsages(object):
|
|||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"*ScopeMismatch*involved factories*",
|
||||
"* def arg2*",
|
||||
"* def arg1*",
|
||||
"test_receives_funcargs_scope_mismatch.py:6: def arg2(arg1)",
|
||||
"test_receives_funcargs_scope_mismatch.py:2: def arg1()",
|
||||
"*1 error*",
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue