From 917ece05f284686958f4b39905cf765fa4126d53 Mon Sep 17 00:00:00 2001 From: William Manley Date: Tue, 8 Sep 2020 12:51:10 +0100 Subject: [PATCH] pytest: Fix deprecation warning when running against pytest 5.4 See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent --- stbt_rig.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stbt_rig.py b/stbt_rig.py index f8f73ca..1e93ddb 100755 --- a/stbt_rig.py +++ b/stbt_rig.py @@ -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