Robust pytest_ignore_collect for multi-version Pytest compatibility#974
Conversation
clalancette
left a comment
There was a problem hiding this comment.
I'll approve the change, but the CI run here is not sufficient; it is only testing up to rcl, which won't test this change at all (I don't think).
|
Actually, Claude thinks we need yet another fix here, which is to add |
|
Still broken, I will try that. |
21feaeb to
1891078
Compare
ec54ce9 to
6374c4e
Compare
6374c4e to
5980129
Compare
5980129 to
b24a1db
Compare
Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
b24a1db to
797ef48
Compare
Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
7586237 to
ab47a9f
Compare
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
|
I just added in yet more changes here. They pass locally. Let's see what happens in CI. |
|
Woohoo, green CI. I've already approved, and since I made changes here, I got @mjcarroll 's OK on this (you can't approve your own PRs). I'm going to merge this and ament/ament_lint#581 , then backport the lot to Lyrical. |
This PR provides a comprehensive and verified fix for the collection and import regressions introduced by the Pytest 8/9 migration.
The Problem
The initial Pytest 8/9 compatibility changes in #972 (backported in #973) caused widespread CI failures on platforms with older Pytest versions (e.g., Ubuntu Noble 24.04, RHEL 10, Windows):
launch/logging/handlers.pyinto a namespace that conflicted with the systemlogging.handlers, causingImportPathMismatchError.launch_testingprevented standardunittestlaunch tests from being correctly wrapped inLaunchTestModule, resulting inTypeErrorfailures due to missing launch fixtures.pytest_launch_collect_makemodulewere renamed in a way that causedPluginValidationErrorwhen using older plugins (likelaunch_ros)..launch.pyfiles as standard Python modules, which failed due to double extensions.The Verified Fix
This version of the PR has been verified locally on Noble (Pytest 7.4.4) with all 387 tests in
launch,launch_testing, andlaunch_pytestpassing.pytest_ignore_collecttolaunch_testingand updated it inlaunchusing a robust signature and string-based path matching. This correctly ignores.launch.pyfiles and standard library collisions across all Pytest versions.pytest_launch_collect_makemodulespec and implementation to include BOTHmodule_path(Pytest 8+) andpath(Pytest 7). This ensures full backward compatibility.test_*.pypatterns, ensuring launch fixtures are correctly injected into all test classes.pythonpath: Addedpythonpath = testtolaunch/pytest.inito ensure test utilities are discoverable.Assisted-by: Gemini CLI:2.0-Flash [run_shell_command, read_file, replace, write_file, git, gh]