Skip to content

Commit 525f9f0

Browse files
rotumjcarroll
authored andcommitted
stop using constructors deprecated in pytest 5.4 (#391)
Signed-off-by: Dan Rose <[email protected]>
1 parent 1011b93 commit 525f9f0

File tree

1 file changed

+12
-2
lines changed
  • launch_testing/launch_testing/pytest

1 file changed

+12
-2
lines changed

launch_testing/launch_testing/pytest/hooks.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,18 @@ def pytest_pycollect_makemodule(path, parent):
110110
if module is not None:
111111
return module
112112
if path.basename == '__init__.py':
113-
return pytest.Package(path, parent)
114-
return pytest.Module(path, parent)
113+
try:
114+
# since https://docs.pytest.org/en/latest/changelog.html#deprecations
115+
# todo: remove fallback once all platforms use pytest >=5.4
116+
return pytest.Package.from_parent(parent, fspath=path)
117+
except AttributeError:
118+
return pytest.Package(path, parent)
119+
try:
120+
# since https://docs.pytest.org/en/latest/changelog.html#deprecations
121+
# todo: remove fallback once all platforms use pytest >=5.4
122+
return pytest.Module.from_parent(parent, fspath=path)
123+
except AttributeError:
124+
return pytest.Module(path, parent)
115125

116126

117127
@pytest.hookimpl(trylast=True)

0 commit comments

Comments
 (0)