Skip to content

refactor(tools): migrate private release tool tests to pytest and pytest-mock#3937

Merged
rickeylev merged 10 commits into
bazel-contrib:mainfrom
rickeylev:migrate-private-release-pytest
Jul 20, 2026
Merged

refactor(tools): migrate private release tool tests to pytest and pytest-mock#3937
rickeylev merged 10 commits into
bazel-contrib:mainfrom
rickeylev:migrate-private-release-pytest

Conversation

@rickeylev

Copy link
Copy Markdown
Collaborator

Migrates release tool unit tests under tests/tools/private/release/ to Pytest and Pytest-mock (mocker fixture).

  • Added pytest-mock dependency to docs/pyproject.toml, updated docs/uv.lock & docs/requirements.txt, and added @pypi//pytest_mock to release test helper deps.
  • Converted release test targets from standard unittest to pytest fixtures.
  • Refactored tests to use the standard mocker fixture from pytest-mock.

Convert release tool tests from unittest.TestCase to standalone pytest functions
with pytest fixtures. Refactor MockGitHub to use state-based verification and
add TypedDict definitions for GitHub API objects.
Add pytest-mock to docs/pyproject.toml and update locked requirements. Refactor release tool tests to use the standard mocker fixture from pytest-mock instead of custom patching helpers.
@rickeylev
rickeylev requested a review from aignas as a code owner July 20, 2026 05:22
…ibility

In WORKSPACE mode, the @pypi repo alias is not defined. Using @dev_pip//pytest_mock ensures compatibility across both WORKSPACE and Bzlmod test environments.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request migrates the release tool tests from the unittest framework to pytest, leveraging pytest-mock and custom fixtures (such as mock_gh, mock_git, and release_tool_env) instead of unittest.TestCase and manual mock patching. Additionally, it refactors the GitHub client (gh.py) and its mock counterpart with TypedDicts and enums, and renames create_tracking_issue to create_release_tracking_issue. A critical issue was found in create_rc_test.py where argparse is used but not imported, which will lead to a NameError during test execution.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread tests/tools/private/release/create_rc_test.py
@rickeylev
rickeylev enabled auto-merge July 20, 2026 05:26
…ible only with Bzlmod

Switches release_test_helper back to @pypi//pytest_mock and marks all release test targets with target_compatible_with = SUPPORTS_BZLMOD to correctly skip analysis in WORKSPACE mode.
@rickeylev

Copy link
Copy Markdown
Collaborator Author

This pr isn't particularly interesting insofar as pytest usage is concerned.

Next pr, I'm going to add a contest.py file, so we'll get a sense of how that gets integrated

@rickeylev
rickeylev merged commit c271d3f into bazel-contrib:main Jul 20, 2026
6 checks passed
@rickeylev
rickeylev deleted the migrate-private-release-pytest branch July 20, 2026 17:23
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