← Back to issue list

fix(tests): skip apt-backed lifecycle test when python3-apt is unavailable

View original Github issue

Metadata

Project
rockcraft
Number
#1347
Type
pull request
State
open
Author
lengau
Labels
—
Created
Updated
Closed
—

Current evaluation

Adds a skipif guard to tests/unit/services/test_lifecycle.py so test_lifecycle_package_repositories is skipped when craft-parts' apt cache bindings are unimportable. Small test-only change (+13/-0, 1 file) from a maintainer; no reviews or comments yet, one unresolved review comment.

Suggested action: needs review

Reason: The change is a 13-line test-only skip guard with a clear rationale (craft_parts.packages.deb._APT_CACHE_AVAILABLE is False when python3-apt cannot be imported, causing PartsLifecycleError), confirmed by the referenced test at tests/unit/services/test_lifecycle.py:104 and python3-apt usage in tools/freeze-requirements.sh and snap/snapcraft.yaml, so CI environments keep exercising it. Review status is 'pending (0 reviewers)' with no CI checks reported, and there is 1 unresolved review comment that is not visible to me, which caps readiness until a maintainer weighs in.

Evaluated by: mr-cal-bot

Impact: 15 Quick Win: 9 Complexity: 8 Confidence: 74 Actionability: 62

Issue body

## Summary `test_lifecycle_package_repositories` fails spuriously in environments where the `python3-apt` bindings are not importable for the active interpreter (e.g. non-distro virtualenvs / sandboxed dev environments). In those cases craft-parts raises: ``` craft_application.errors.PartsLifecycleError: Package backend 'apt' is not supported on this environment. ``` (`craft_parts.packages.deb._APT_CACHE_AVAILABLE` is `False` because `from .apt_cache import AptCache` raises `ImportError`.) This PR detects that situation in the test module and skips the affected test with a clear reason instead of failing. Environments with working apt bindings (e.g. distro Python on CI runners) are unaffected and continue to exercise the test. ## Validation - Before: `1 failed, 17 passed` in a python3.13 venv without python3-apt. - After: `17 passed, 1 skipped` in the same environment; `ruff check` and pre-commit hooks pass. --- - [x] I've followed the [contribution guidelines](https://github.com/canonical/rockcraft/blob/main/CONTRIBUTING.md). - [x] I've signed the [CLA](http://www.ubuntu.com/legal/contributors/). - [x] I've successfully run `make lint && make test` (targeted: the affected test module).

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 15
Quick Win: 9
Complexity: 8
Confidence: 74
Actionability: 62
needs review Adds a skipif guard to tests/unit/services/test_lifecycle.py so test_lifecycle_package_repositories is skipped when craft-parts' apt cache bindings are unimportable. Small test-only change (+13/-0, 1 file) from a maintainer; no reviews or comments yet, one unresolved review comment.
stealth/space-bunny-alpha
Impact: 18
Quick Win: 10
Complexity: 12
Confidence: 86
Actionability: 65
needs review Skips an apt-backed lifecycle test when python3-apt bindings cannot be imported, preventing spurious failures in non-distro environments; awaiting review.
qwen3.6-35b-a3b-mtp-q6
Impact: 25
Quick Win: 21
Staleness: 35
Complexity: 15
Confidence: 75
needs review Skips apt-backed lifecycle test when python3-apt bindings are unavailable, preventing spurious test failures in non-distro environments.
qwen/qwen3.6-35b-a3b
Staleness: 5
Complexity: 10
Confidence: 90
needs review Skips the test_lifecycle_package_repositories test when python3-apt bindings are unavailable, preventing spurious failures in sandboxed environments. Currently awaiting maintainer review with passing CI.
qwen/qwen3.6-35b-a3b
Staleness: 5
Complexity: 5
Confidence: 90
needs review Skips the apt-backed lifecycle test when python3-apt bindings are unavailable, preventing spurious failures in sandboxed or non-distro environments. Currently awaiting maintainer review with no CI checks yet.

Update history

Date Change
updated
created

Related issues

No related issues found above the similarity threshold.