Skip to content

refactor(pytest): extract image test helper package - #416

Merged
Nan Liu (liunan-ms) merged 1 commit into
microsoft:mainfrom
reubeno:refactor/extract-pytest-helper
Oct 29, 2026
Merged

Nan Liu (liunan-ms) merged 1 commit into
microsoft:mainfrom
reubeno:refactor/extract-pytest-helper

Conversation

@reubeno

Copy link
Copy Markdown
Member

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 in projectconfig, 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.Env and 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.
  • Mechanically compared moved implementation/test bodies against upstream; original tests are retained, with focused coverage for command option forwarding, configuration preparation, shared venv invocation/errors, and nil properties.
  • No schema or snapshot changes. Discarded generated CLI documentation drift limited to the local 0.0.0-devel version label.

mage fix all completed Go formatting/linting with zero issues, then stopped at optional Python autofixing because ruff is unavailable. No Python files changed; the required mage all pipeline passed independently. Native E2E tests were not run.

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>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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/pythonenv and keeps property serialization and placeholder tokens in projectconfig.
  • 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

@reubeno
reuben olinsky (reubeno) marked this pull request as ready for review October 29, 2026 16:40
@liunan-ms
Nan Liu (liunan-ms) merged commit 4725eaf into microsoft:main Oct 29, 2026
26 of 27 checks passed
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.

3 participants