Skip to content

Add compatibility with Pytest 5.4.0+ - #32

Merged
RonnyPfannschmidt merged 1 commit into
pytest-dev:masterfrom
stanislavlevin:pytest_getfslineno
Jun 2, 2020
Merged

RonnyPfannschmidt merged 1 commit into
pytest-dev:masterfrom
stanislavlevin:pytest_getfslineno

Conversation

@stanislavlevin

@stanislavlevin stanislavlevin commented May 7, 2020 •

Copy link
Copy Markdown
Contributor

'getfslineno' has been removed from 'compat' in Pytest [0].
However, that function was just the wrapper of
'_pytest._code.source.getfslineno'. The latter exists in Pytest
since, at least, 3.0.0.

[0]: pytest-dev/pytest@9c7f1d9b3.

Fixes: #30

'getfslineno' has been removed from 'compat' in Pytest [0].
However, that function was just the wrapper of
'_pytest._code.source.getfslineno'. The latter exists in Pytest
since, at least, 3.0.0.

[0]: pytest-dev/pytest@9c7f1d9b3.

Fixes: pytest-dev#30
Signed-off-by: Stanislav Levin <slev@altlinux.org>
bmwiedemann added a commit to bmwiedemann/openSUSE that referenced this pull request May 28, 2020
https://build.opensuse.org/request/show/803983
by user mcepl + maxlin_factory
- Add pytest5-compat.patch to make the test suite compatible
  with pytest 5.4.0+ (gh#pytest-dev/pytest-forked#32)
@webknjaz

webknjaz commented Jun 2, 2020

Copy link
Copy Markdown
Member

@RonnyPfannschmidt looks like I hit it too while trying to debug #33. It seems mergeable.

@RonnyPfannschmidt
RonnyPfannschmidt merged commit 74b3e8b into pytest-dev:master Jun 2, 2020
@RonnyPfannschmidt

Copy link
Copy Markdown
Member

merged, someone has to step up to do a release

else:
path, lineno = getfslineno(item)
from _pytest._code.source import getfslineno
path, lineno = getfslineno(item)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR this returns path = '' and lineno = -1 in my setup. Dunno if it's generally broken in pytest 5.4. It may need some extra investigation.

path, lineno = item._getfslineno()
else:
path, lineno = getfslineno(item)
from _pytest._code.source import getfslineno

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been relocated to .code 27 days ago: https://github.com/pytest-dev/pytest/pull/7171/files#diff-ef66cddae564a1d8faabcab1bc4dccb4L282

But it's also accessible via __init__ so just removing .source would "fix" it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its entirely possible this has been incorrect for years and was just missed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, before the mentioned relocation, it was correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'Function' object has no attribute '_getfslineno'

3 participants