From ef5917f0bfd19fe159f21e0f547dc13f2b2a309e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 08:20:16 -0400 Subject: [PATCH] Add consider_namespace_packages=False (#766) (#778) * Add consider_namespace_packages=False Signed-off-by: Tony Najjar (cherry picked from commit 07f43328054c03067b470d1c9bd707cb1e52d691) Co-authored-by: Tony Najjar --- launch_testing/launch_testing/pytest/hooks.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/launch_testing/launch_testing/pytest/hooks.py b/launch_testing/launch_testing/pytest/hooks.py index de0035f76..174c4c476 100644 --- a/launch_testing/launch_testing/pytest/hooks.py +++ b/launch_testing/launch_testing/pytest/hooks.py @@ -157,8 +157,10 @@ def makeitem(self, *args, **kwargs): return LaunchTestItem.from_parent(*args, **kwargs) def collect(self): - if _pytest_version_ge(7): - # self.path exists since 7 + if _pytest_version_ge(8, 1, 0): + from _pytest.pathlib import import_path + module = import_path(self.path, root=None, consider_namespace_packages=False) + elif _pytest_version_ge(7, 0, 0): from _pytest.pathlib import import_path module = import_path(self.path, root=None) else: @@ -173,7 +175,10 @@ def collect(self): def find_launch_test_entrypoint(path): try: - if _pytest_version_ge(7): + if _pytest_version_ge(8, 1, 0): + from _pytest.pathlib import import_path + module = import_path(path, root=None, consider_namespace_packages=False) + elif _pytest_version_ge(7, 0, 0): from _pytest.pathlib import import_path module = import_path(path, root=None) else: