refactor(tests): standardize tests to follow pytest conventions#3242
refactor(tests): standardize tests to follow pytest conventions#3242agsaru wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3242 +/- ##
=========================================
Coverage ? 28.86%
=========================================
Files ? 381
Lines ? 52467
Branches ? 9260
=========================================
Hits ? 15145
Misses ? 36313
Partials ? 1009 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates how a pip index-related regression test mocks Pip._call, and fixes a regex string literal to avoid escape-sequence issues when extracting package names from pip error output.
Changes:
- Replace
monkeypatch/MagicMockusage withpytest-mock’smocker.patch.objectin the pip indices test. - Use a raw string for the
\w*regex inpip.pyto prevent invalid escape-sequence behavior.
Reviewed changes
Copilot reviewed 64 out of 64 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/plugins/pip/test_pip_indices.py | Switches test mocking approach to mocker.patch.object for _call. |
| metaflow/plugins/pypi/pip.py | Converts regex to a raw string for correct escaping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR standardizes 64 test files from unittest-style classes to pytest conventions — replacing
Confidence Score: 4/5Safe to merge; the only concern is a test-isolation gap that only manifests when one specific test is already failing. The vast majority of the 64 changed files are straightforward mechanical conversions that preserve test logic. The one notable gap is in test_serializer_lifecycle.py: test_retry_fires_via_real_import_hook cleans up _interceptor._watched and _interceptor._processed inline after assertions, so if the import hook doesn't fire as expected and an assertion fails, the interceptor is left with a stale watched entry. The original try/finally guaranteed cleanup even on failure; the refactored version does not. test/unit/test_serializer_lifecycle.py — the test_retry_fires_via_real_import_hook function's interceptor cleanup is not covered by isolated_store and is unreachable on assertion failure. Important Files Changed
Reviews (5): Last reviewed commit: "added spacing" | Re-trigger Greptile |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
Can you fix the pre-commit hook issues? |
|
Also, this diff is too large - ideally we should be splitting it into multiple PRs that we can tackle this one at a time. |
|
@talsperre fixed the pre commit. So now do I have to make multiple PRs or what? |
|
@agsaru I was just saying that let's make each PR more readable - a few modules at a time. So yes, lets split it. |
|
ok I will do that |
PR Type
Summary
This PR refactors existing tests to align with the project's testing guidelines. Using
pytestinplace ofunittest. Replacingunittest.mockwithpytest-mock