refactor(tools): migrate private release tool tests to pytest and pytest-mock#3937
Conversation
…ures and update AGENTS.md
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.
…lease_test_helper
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.
…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.
…ickeylev/rules_python into migrate-private-release-pytest
There was a problem hiding this comment.
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.
…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.
|
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 |
Migrates release tool unit tests under
tests/tools/private/release/to Pytest and Pytest-mock (mockerfixture).pytest-mockdependency todocs/pyproject.toml, updateddocs/uv.lock&docs/requirements.txt, and added@pypi//pytest_mockto release test helperdeps.mockerfixture frompytest-mock.