Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions launch/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import pytest


<<<<<<< HEAD

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

def _pytest_version_ge(major, minor=0, patch=0):
"""Return True if pytest version is >= the given version."""
pytest_version = tuple(int(v) for v in pytest.__version__.split('.'))
Expand All @@ -42,3 +43,15 @@ def pytest_ignore_collect(collection_path, config):
else:
def pytest_ignore_collect(path, config):
return _should_ignore(path)
=======
def pytest_ignore_collect(collection_path=None, path=None):
if collection_path is not None:
path = collection_path
# pytest doctest messes up when trying to import .launch.py packages, ignore them.
# It also messes up when trying to import launch.logging.handlers due to conflicts with
# logging.handlers, ignore that as well.
return str(path).endswith((
'.launch.py',
str(PurePath('logging') / 'handlers.py'),
))
>>>>>>> 0630831 (Fix Pytest 8/9 compatibility and coroutine leaks in launch_pytest (#972))
23 changes: 23 additions & 0 deletions launch_testing/launch_testing/pytest/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def find_launch_test_entrypoint(path):
return None


<<<<<<< HEAD
@pytest.hookimpl(tryfirst=True)
def pytest_ignore_collect(collection_path=None, path=None, config=None):
# Pytest 8.x signature: (collection_path, path, config)
Expand All @@ -221,6 +222,8 @@ def pytest_ignore_collect(collection_path=None, path=None, config=None):
return False


=======
>>>>>>> 0630831 (Fix Pytest 8/9 compatibility and coroutine leaks in launch_pytest (#972))
if _pytest_version_ge(8):
def pytest_pycollect_makemodule(module_path, parent):
return _pytest_pycollect_makemodule(module_path, parent)
Expand All @@ -234,7 +237,11 @@ def _pytest_pycollect_makemodule(path, parent):
if entrypoint is not None:
ihook = parent.session.gethookproxy(path)
module = ihook.pytest_launch_collect_makemodule(
<<<<<<< HEAD
module_path=path, path=path, parent=parent, entrypoint=entrypoint
=======
module_path=path, parent=parent, entrypoint=entrypoint
>>>>>>> 0630831 (Fix Pytest 8/9 compatibility and coroutine leaks in launch_pytest (#972))
)
if module is not None:
return module
Expand All @@ -261,6 +268,7 @@ def _pytest_pycollect_makemodule(path, parent):


@pytest.hookimpl(trylast=True)
<<<<<<< HEAD
def pytest_launch_collect_makemodule(module_path, path, parent, entrypoint):
p = module_path or path
if _pytest_version_ge(7):
Expand All @@ -275,6 +283,21 @@ def pytest_launch_collect_makemodule(module_path, path, parent, entrypoint):
decorator = decorator.with_args(*mark.args, **mark.kwargs)
module.add_marker(decorator)
return module
=======
def pytest_launch_collect_makemodule(module_path, parent, entrypoint):
marks = getattr(entrypoint, 'pytestmark', [])
if marks and any(m.name == 'launch_test' for m in marks):
if _pytest_version_ge(7):
path = pathlib.Path(module_path)
module = LaunchTestModule.from_parent(parent=parent, path=path)
else:
module = LaunchTestModule.from_parent(parent=parent, fspath=module_path)
for mark in marks:
decorator = getattr(pytest.mark, mark.name)
decorator = decorator.with_args(*mark.args, **mark.kwargs)
module.add_marker(decorator)
return module
>>>>>>> 0630831 (Fix Pytest 8/9 compatibility and coroutine leaks in launch_pytest (#972))


def pytest_addhooks(pluginmanager):
Expand Down
4 changes: 4 additions & 0 deletions launch_testing/launch_testing/pytest/hookspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@


@pytest.hookspec(firstresult=True)
<<<<<<< HEAD
def pytest_launch_collect_makemodule(module_path, path, parent, entrypoint):
=======
def pytest_launch_collect_makemodule(module_path, parent, entrypoint):
>>>>>>> 0630831 (Fix Pytest 8/9 compatibility and coroutine leaks in launch_pytest (#972))
"""Make launch test module appropriate for the found test entrypoint."""
pass