Skip to content

Refactor Alternatives pytest parameter selection into testable helpers#5

Merged
Code0x58 merged 1 commit into
masterfrom
codex/refactor-pytest_parametrize-blocks-into-helpers
May 8, 2026
Merged

Refactor Alternatives pytest parameter selection into testable helpers#5
Code0x58 merged 1 commit into
masterfrom
codex/refactor-pytest_parametrize-blocks-into-helpers

Conversation

@Code0x58
Copy link
Copy Markdown
Owner

@Code0x58 Code0x58 commented May 8, 2026

Motivation

  • Make the logic that selects implementation callables for pytest parametrization deterministic and directly unit-testable instead of embedded inline in decorators.
  • Allow explicit verification of behavior across boolean options (only_default, double_reference) and keep pytest-friendly callable IDs.

Description

  • Extracted the implementation-selection logic from Alternatives.pytest_parametrize(...) into a new private method Alternatives._select_parametrize_implementations(...) and updated the decorator to use it.
  • Extracted the pair-selection logic from Alternatives.pytest_parametrize_pairs(...) into a new private method Alternatives._select_parametrize_pairs(...) and updated the decorator to use it.
  • Preserved existing semantics for only_default, double_reference, exclusion of the reference implementation in pair mode when appropriate, and use of underlying callables for readable pytest IDs.
  • Added focused tests in test_pytest_util.py that assert the exact callable lists returned by the new helpers across all boolean combinations.

Testing

  • Ran uv run --dev pytest and all tests passed: 33 passed.
  • Ran uv run --dev ruff format --check . and formatting checks passed.
  • Attempted uv run --dev pyrefly check . but pyrefly is not available in this environment so it was not run successfully.
  • Ran mypy . which reported pre-existing type-check issues in alternative.py unrelated to these changes.

Codex Task

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@6594c5d). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             master        #5   +/-   ##
==========================================
  Coverage          ?   100.00%           
==========================================
  Files             ?         1           
  Lines             ?       189           
  Branches          ?         0           
==========================================
  Hits              ?       189           
  Misses            ?         0           
  Partials          ?         0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Code0x58 Code0x58 merged commit 8bc0620 into master May 8, 2026
5 checks passed
@Code0x58 Code0x58 deleted the codex/refactor-pytest_parametrize-blocks-into-helpers branch May 8, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant