-
Notifications
You must be signed in to change notification settings - Fork 2.4k
tests: make test independent of git setting of default branch #10656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR makes the Git-based tests independent of the environment’s default branch by explicitly initializing test repositories with 'main' as the default branch and updating the corresponding expected error message to reference 'refs/heads/main' instead of 'refs/heads/master'. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- To truly decouple the test from a specific default branch name, consider deriving the expected ref from the created repo (e.g., using
repo.default_branchor a fixture parameter) instead of hardcoding'main'in the error message assertion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- To truly decouple the test from a specific default branch name, consider deriving the expected ref from the created repo (e.g., using `repo.default_branch` or a fixture parameter) instead of hardcoding `'main'` in the error message assertion.
## Individual Comments
### Comment 1
<location> `tests/vcs/git/test_backend.py:279` </location>
<code_context>
expected_short = (
- f"Failed to clone {source_url} at 'refs/heads/master',"
+ f"Failed to clone {source_url} at 'refs/heads/main',"
f" unable to acquire file lock for {tag_ref}."
)
</code_context>
<issue_to_address>
**suggestion (testing):** The assertion on the exact error string is quite brittle; consider relaxing it to focus on the important parts.
`assert str(exc_info.value) == expected_short` ties the test to the exact wording (including punctuation and spacing), so minor message refactors will break it even if behavior is unchanged. Prefer asserting on key substrings (e.g., branch ref and lock path) or using a regex so the test verifies `refs/heads/main` and the tag lock are mentioned without over-constraining the full message.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
pre-commit.ci autofix |
b9a7cec to
b77fdbf
Compare
Summary by Sourcery
Ensure git backend tests use a repository with a fixed 'main' default branch and update related expectations to be independent of external git default-branch settings.
Tests: