Skip to content

Run pytest unless SKIP_PYTEST=1; fix lint test collection from repo root - #57

Merged
palcode merged 1 commit into
mainfrom
chore/tidy-after-55
Nov 24, 2026
Merged

palcode merged 1 commit into
mainfrom
chore/tidy-after-55

Conversation

@palcode

@palcode palcode commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Two small fixes found during the ODL-86 work. No flight, gate, OpenVINS, EKF2, world or profile change.

1. run-regression.sh skipped pytest when SCENARIOS was set

regression_20261124_153609 ran SCENARIOS="mc_gps baseline" and printed [REG] skipping pytest. Root cause: with SCENARIOS set, pytest only ran if the word pytest was listed. That contradicts the documented SKIP_PYTEST=1 SCENARIOS=<one> usage, which implies pytest runs by default.

  • pytest now runs unless SKIP_PYTEST=1 (reg_pytest_decision in regression-lib.sh).
  • SCENARIOS=pytest still means pytest only.
  • The skip message now gives the reason: skipping pytest (SKIP_PYTEST=1).
  • Found while testing: if pytest.txt had no N passed line, grep | head | awk under pipefail + set -e aborted the run before pytest.json and the report were written. That is fixed too.
  • Tests in test_regression_harness.py cover the decision function, pytest running with SCENARIOS=mc_gps / mc_gps pytest / pytest (and whether it flies), and the explicit skip reason.

2. Six lint test collection errors from pytest ros2_ws/src

Root cause: the ament linters are installed in the dev image, so missing deps were not the cause. test_flake8.py, test_pep257.py and test_copyright.py exist with the same basenames in drone_mission_manager, drone_perception and drone_telemetry, and the test directories have no __init__.py. pytest's default prepend import mode imports them all under one module name, so the perception and telemetry copies failed with "import file mismatch" (3 + 3 errors).

  • A root pytest.ini sets --import-mode=importlib and registers the lint markers. colcon runs each package from its own directory, so it does not use this file.
  • The lint tests used cwd-relative paths (argv=[] / ['.', 'test']), so from the root they linted the whole checkout. They now lint their own package, found from __file__.
  • If the ament linters are not importable, the tests now skip explicitly with a reason (pytest.importorskip) instead of passing silently.
  • The existing flake8 and pep257 findings in these packages predate this change. Those tests are now strict xfail with a reason, so they will flag once the package is clean.
  • ament_copyright has no AGPL license in its list, so it reported license=<unknown> for every file and could never pass. test_copyright now checks the SPDX AGPL-3.0-only and copyright lines directly, and it passes.

Checks

  • Regression pytest set: 373 passed (was 366; +7 new).
  • pytest ros2_ws/src from the root: 380 passed, 6 xfailed, 0 collection errors.
  • Per package: mission_manager 97 passed / 2 xfailed, perception 32 / 2, telemetry 5 / 2, localization 246 passed.
  • Live SCENARIOS=pytest ./scripts/run-regression.sh: PASS, 373 passed.
  • shellcheck (warning) clean; gitleaks clean.

run-regression.sh only ran pytest when SCENARIOS was unset or listed
"pytest", so SCENARIOS="mc_gps baseline" printed 'skipping pytest'.
pytest now runs unless SKIP_PYTEST=1 (reg_pytest_decision), the skip
message names the reason, and a pytest.txt with no 'N passed' line no
longer aborts the script under pipefail before the report is written.

pytest ros2_ws/src failed collection with 6 'import file mismatch'
errors: test_flake8/test_pep257/test_copyright share basenames across
packages and prepend import mode collides. A root pytest.ini sets
--import-mode=importlib. The lint tests now lint their own package from
any cwd, importorskip the ament linters with a reason, mark existing
flake8/pep257 findings strict xfail, and test_copyright checks the SPDX
AGPL-3.0-only header directly (ament_copyright has no AGPL license).
@palcode
palcode merged commit c7f2253 into main Nov 24, 2026
4 checks passed
@palcode
palcode deleted the chore/tidy-after-55 branch November 24, 2026 11:33
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.

1 participant