Skip to content

fix: add get_launch_test_fixture_scope for pytest compatibility#949

Open
wep21 wants to merge 1 commit intoros2:rollingfrom
wep21:fix-947
Open

fix: add get_launch_test_fixture_scope for pytest compatibility#949
wep21 wants to merge 1 commit intoros2:rollingfrom
wep21:fix-947

Conversation

@wep21
Copy link

@wep21 wep21 commented Feb 28, 2026

Description

Fixes #947

Is this user-facing behavior change?

Did you use Generative AI?

codex 5.3

Additional Information

before

❯ PYTHONPATH=launch_pytest:launch_testing:launch:../ament_index/ament_index_python/ uvx --with pytest --with osrf_pycommon --with typing_extensions --with pyyaml --with lark pytest /Users/daisuke/workspace/launch/launch_pytest/test/launch_pytest/tools/test_process.py::test_sync_process_tools -q
E                                                                                                                                                  [100%]
========================================================================= ERRORS =========================================================================
_______________________________________________________ ERROR at setup of test_sync_process_tools ________________________________________________________
file /Users/daisuke/workspace/launch/launch_pytest/test/launch_pytest/tools/test_process.py, line 65
  @pytest.mark.launch(fixture=launch_description)
  def test_sync_process_tools(dut, launch_context):
E       fixture 'launch_context' not found
>       available fixtures: LineMatcher, _config_for_test, _pytest, _sys_snapshot, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, capteesys, doctest_namespace, dut, launch_description, linecomp, monkeypatch, pytestconfig, pytester, record_property, record_testsuite_property, record_xml_attribute, recwarn, subtests, testdir, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/Users/daisuke/workspace/launch/launch_pytest/test/launch_pytest/tools/test_process.py:65
==================================================================== warnings summary ====================================================================
launch_pytest/test/launch_pytest/tools/test_process.py:49
  /Users/daisuke/workspace/launch/launch_pytest/test/launch_pytest/tools/test_process.py:49: PytestUnknownMarkWarning: Unknown pytest.mark.launch - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.launch(fixture=launch_description)

launch_pytest/test/launch_pytest/tools/test_process.py:65
  /Users/daisuke/workspace/launch/launch_pytest/test/launch_pytest/tools/test_process.py:65: PytestUnknownMarkWarning: Unknown pytest.mark.launch - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.launch(fixture=launch_description)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================ short test summary info =================================================================
ERROR launch_pytest/test/launch_pytest/tools/test_process.py::test_sync_process_tools
2 warnings, 1 error in 0.12s

~/workspace/launch rolling
❯ PYTHONPATH=launch_pytest:launch_testing:launch:../ament_index/ament_index_python \
      uvx --with pytest --with osrf_pycommon --with typing_extensions --with pyyaml --with lark \
      pytest -p launch_pytest.plugin \
      /Users/daisuke/workspace/launch/launch_pytest/test/launch_pytest/tools/test_process.py::test_sync_process_tools -q

================================================================== ERRORS ==================================================================
________________________________________ ERROR collecting test/launch_pytest/tools/test_process.py _________________________________________
../../.cache/uv/archive-v0/LH_vSsIIXaIhCxrT9it7P/lib/python3.14/site-packages/pluggy/_hooks.py:512: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../.cache/uv/archive-v0/LH_vSsIIXaIhCxrT9it7P/lib/python3.14/site-packages/pluggy/_manager.py:120: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
launch_pytest/launch_pytest/plugin.py:239: in pytest_pycollect_makeitem
    scope = fixture._pytestfixturefunction.scope
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   AttributeError: 'FixtureFunctionDefinition' object has no attribute '_pytestfixturefunction'. Did you mean: '_fixture_function'?
========================================================= short test summary info ==========================================================
ERROR launch_pytest/test/launch_pytest/tools/test_process.py - AttributeError: 'FixtureFunctionDefinition' object has no attribute '_pytestfixturefunction'. Did you mean: '_fixture_function'?
1 error in 0.06s
ERROR: found no collectors for /Users/daisuke/workspace/launch/launch_pytest/test/launch_pytest/tools/test_process.py::test_sync_process_tools

after

❯ PYTHONPATH=launch_pytest:launch_testing:launch:../ament_index/ament_index_python \
      uvx --with pytest --with osrf_pycommon --with typing_extensions --with pyyaml --with lark \
      pytest -p launch_pytest.plugin \
      /Users/daisuke/workspace/launch/launch_pytest/test/launch_pytest/tools/test_process.py::test_sync_process_tools -q
.                                                                                                                                    [100%]
============================================================= warnings summary =============================================================
test/launch_pytest/tools/test_process.py::test_sync_process_tools
  /Users/daisuke/workspace/launch/launch_pytest/launch_pytest/fixture.py:75: DeprecationWarning: 'asyncio.get_event_loop_policy' is deprecated and slated for removal in Python 3.16
    loop = asyncio.get_event_loop_policy().new_event_loop()

test/launch_pytest/tools/test_process.py::test_sync_process_tools
  /Users/daisuke/workspace/launch/launch_pytest/launch_pytest/fixture.py:76: DeprecationWarning: 'asyncio.get_event_loop_policy' is deprecated and slated for removal in Python 3.16
    policy = asyncio.get_event_loop_policy()

test/launch_pytest/tools/test_process.py::test_sync_process_tools
  /Users/daisuke/workspace/launch/launch_pytest/launch_pytest/fixture.py:87: DeprecationWarning: 'asyncio.set_event_loop_policy' is deprecated and slated for removal in Python 3.16
    asyncio.set_event_loop_policy(None)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
1 passed, 3 warnings in 5.04s

Signed-off-by: wep21 <daisuke.nishimatsu1021@gmail.com>
@wep21
Copy link
Author

wep21 commented Feb 28, 2026

@claraberendsen could you review this PR?

@claraberendsen claraberendsen requested a review from sloretz March 3, 2026 22:41
@claraberendsen
Copy link

claraberendsen commented Mar 3, 2026

Thanks @wep21 for setting this up ❤️ . Checking if it solves the build regression on Resolute. Build Status

@sloretz I would appreciate your review here of the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

launch_pytest not building with pytest >= 8.4

2 participants