Skip to content

Commit

Permalink
pytest: Fix deprecation warning when running against pytest 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
wmanley committed Sep 8, 2020
1 parent 157bf61 commit 917ece0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion stbt_rig.py
Expand Up @@ -1223,7 +1223,13 @@ def pytest_addoption(parser):

def pytest_collect_file(path, parent):
if path.ext == ".py":
return StbtCollector(path, parent)
if hasattr(StbtCollector, "from_parent"):
# pytest >v5.4
return StbtCollector.from_parent(parent=parent, fspath=path)
else:
# Backwards compat
# https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
return StbtCollector(path, parent)
else:
return None

Expand Down

0 comments on commit 917ece0

Please sign in to comment.