Repository navigation
refactor(pytest): extract image test helper package - #416
Merged
Nan Liu (liunan-ms) merged 1 commit intoOct 29, 2026
Merged
Conversation
Move pytest configuration decoding, legacy suite preparation and validation, execution, and tests into internal/pytest. Call the helper directly from image commands and share Python environment and image-metadata utilities through their owning lower-level packages, preserving existing CLI behavior and diagnostics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the pytest-helper extraction.
No open issues 🎉
What changed in this PR
Extracts image-test pytest execution into internal/pytest, continuing the separation of reusable helpers from image commands begun in #415. The refactor preserves existing behavior while leaving artifact selection and framework dispatch in the command layer.
Changes:
- Moves pytest configuration preparation and execution into a dedicated package.
- Shares Python virtual-environment creation through
utils/pythonenvand keeps property serialization and placeholder tokens inprojectconfig. - Relocates existing tests and adds focused coverage for option forwarding, venv errors, and nil properties.
| File | Description |
|---|---|
internal/utils/pythonenv/pythonenv.go |
Extracts shared Python venv creation. |
internal/utils/pythonenv/pythonenv_test.go |
Tests venv invocation and command failures. |
internal/pytest/runner.go |
Relocates pytest execution and argument construction. |
internal/pytest/runner_test.go |
Moves runner tests and adds missing-config checks. |
internal/pytest/config.go |
Extracts configuration decoding, path resolution, and validation. |
internal/pytest/config_internal_test.go |
Relocates configuration preparation tests. |
internal/projectconfig/testsuite.go |
Defines shared image argument placeholders. |
internal/projectconfig/image.go |
Adds shared image-property JSON serialization. |
internal/projectconfig/image_test.go |
Verifies nil properties serialize without mutation. |
internal/app/azldev/cmds/image/test.go |
Dispatches pytest tests directly to the extracted helper. |
internal/app/azldev/cmds/image/test_test.go |
Verifies image and JUnit option forwarding. |
internal/app/azldev/cmds/image/test_internal_test.go |
Removes configuration tests relocated to pytest. |
internal/app/azldev/cmds/image/list.go |
Uses shared property serialization. |
internal/app/azldev/cmds/image/lisarunner.go |
Uses shared venv, serialization, and placeholder helpers. |
Review effort: Balanced
reuben olinsky (reubeno)
marked this pull request as ready for review
October 29, 2026 16:40
Nan Liu (liunan-ms)
approved these changes
Oct 29, 2026
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extract the existing image-test pytest integration into
internal/pytest, including configuration decoding, config-relative working-directory resolution, suite validation, environment setup, argument construction, and invocation. The image command retains artifact/test selection and framework dispatch, and calls the helper directly without forwarding wrappers.Move the existing shared venv-creation code into
utils/pythonenv. Keep property serialization and shared argument tokens inprojectconfig, so LISA and image listing do not depend on pytest-owned utilities.This is the next behavior-preserving extraction after #415. Existing install modes, venv locations, globbing, placeholders, arguments, diagnostics, and JUnit behavior are preserved. No new CLI/config fields, artifact policies, or result-handling semantics are introduced. The runner still uses
azldev.Envand image-shaped inputs; shared execution contracts and further decoupling remain separate work.Validation
mage all— passed on the rebased candidate, including code generation/build, unit tests, default quality checks, scenarios, and CLI/schema generation.git diff --check upstream/main...HEAD— passed.0.0.0-develversion label.mage fix allcompleted Go formatting/linting with zero issues, then stopped at optional Python autofixing becauseruffis unavailable. No Python files changed; the requiredmage allpipeline passed independently. Native E2E tests were not run.