From 5cfa54cfcf690d952859f083e803364564a2ba95 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Fri, 13 Mar 2020 18:17:17 -0500 Subject: [PATCH 1/2] stop using constructors deprecated in pytest5 ``` =============================== warnings summary =============================== /opt/ros/master/install/lib/python3.8/site-packages/launch_testing/pytest/hooks.py:113 /opt/ros/master/install/lib/python3.8/site-packages/launch_testing/pytest/hooks.py:113 /opt/ros/master/install/lib/python3.8/site-packages/launch_testing/pytest/hooks.py:113: PytestDeprecationWarning: direct construction of Package has been deprecated, please use Package.from_parent return pytest.Package(path, parent) /opt/ros/master/install/lib/python3.8/site-packages/launch_testing/pytest/hooks.py:114: 37 tests with warnings /opt/ros/master/install/lib/python3.8/site-packages/launch_testing/pytest/hooks.py:114: PytestDeprecationWarning: direct construction of Module has been deprecated, please use Module.from_parent return pytest.Module(path, parent) -- Docs: https://docs.pytest.org/en/latest/warnings.html ================= 324 passed, 39 warnings in 66.09s (0:01:06) ================== ``` Signed-off-by: Dan Rose --- launch_testing/launch_testing/pytest/hooks.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/launch_testing/launch_testing/pytest/hooks.py b/launch_testing/launch_testing/pytest/hooks.py index 52d39d612..cfe1a01f6 100644 --- a/launch_testing/launch_testing/pytest/hooks.py +++ b/launch_testing/launch_testing/pytest/hooks.py @@ -110,8 +110,16 @@ def pytest_pycollect_makemodule(path, parent): if module is not None: return module if path.basename == '__init__.py': - return pytest.Package(path, parent) - return pytest.Module(path, parent) + try: + # since pytest 5 + return pytest.Package.from_parent(parent, fspath=path) + except AttributeError: + return pytest.Package(path, parent) + try: + # since pytest 5 + return pytest.Module.from_parent(parent, fspath=path) + except AttributeError: + return pytest.Module(path, parent) @pytest.hookimpl(trylast=True) From 58b4ed0f51dcb80c7a49f9f2f439271a5c1588ca Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Wed, 18 Mar 2020 14:20:51 -0500 Subject: [PATCH 2/2] PR feedback Signed-off-by: Dan Rose --- launch_testing/launch_testing/pytest/hooks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/launch_testing/launch_testing/pytest/hooks.py b/launch_testing/launch_testing/pytest/hooks.py index cfe1a01f6..7bc519320 100644 --- a/launch_testing/launch_testing/pytest/hooks.py +++ b/launch_testing/launch_testing/pytest/hooks.py @@ -111,12 +111,14 @@ def pytest_pycollect_makemodule(path, parent): return module if path.basename == '__init__.py': try: - # since pytest 5 + # since https://docs.pytest.org/en/latest/changelog.html#deprecations + # todo: remove fallback once all platforms use pytest >=5.4 return pytest.Package.from_parent(parent, fspath=path) except AttributeError: return pytest.Package(path, parent) try: - # since pytest 5 + # since https://docs.pytest.org/en/latest/changelog.html#deprecations + # todo: remove fallback once all platforms use pytest >=5.4 return pytest.Module.from_parent(parent, fspath=path) except AttributeError: return pytest.Module(path, parent)