Merge pull request #4929 from blueyed/fix-_factorytraceback-offset

Fix line offsets with `ScopeMismatch` errors
This commit is contained in:
Daniel Hahler 2019-03-20 01:30:58 +01:00 committed by GitHub
commit 714f2113bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -0,0 +1 @@
Fix line offsets with ``ScopeMismatch`` errors.

View File

@ -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):

View File

@ -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*",
]
)