refactor(tests): core logic unit tests to follow test conventions#3250
refactor(tests): core logic unit tests to follow test conventions#3250agsaru wants to merge 6 commits into
Conversation
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 refactors and modernizes a set of unit tests to improve readability, determinism, and maintainability by introducing fixtures, parametrization, clearer test naming, and stronger assertions.
Changes:
- Refactored multiple unit tests to use
pytestfixtures/parametrize patterns and clearer assertions. - Improved determinism in tests by avoiding reliance on ambient environment state (e.g., OS env, time-based uniqueness).
- Reorganized test files with consistent section headers and more descriptive docstrings/ids.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/test_tutorial_01_02_csv_parsing.py | Parametrizes CSV parsing tests and adjusts sample CSV data/constants. |
| test/unit/test_task_log_metadata_fetch.py | Adds parametrization ids and improves test organization/readability. |
| test/unit/test_system_context.py | Consolidates repetitive tests via parametrization and improves naming/docstrings. |
| test/unit/test_sourceless_dag_node.py | Introduces fixtures and strengthens assertions around sourceless graphs. |
| test/unit/test_secrets_decorator.py | Improves determinism (env collision), adds ids/docstrings, and refactors assertions. |
| test/unit/test_remove_decorator.py | Introduces a fixture for step setup and splits success/failure cases. |
| test/unit/test_pypi_parsers.py | Uses pytest.raises, parametrizes requirements parsing, and improves naming. |
| test/unit/test_packaging_utils.py | Parametrizes hidden-directory walk tests using tmp_path. |
| test/unit/test_package_suffixes_mutator.py | Reworks tests with fixtures/factories and parametrizes init behavior. |
| test/unit/test_metaflow_version.py | Adds parametrization ids for clearer test output. |
| test/unit/test_graph_structure.py | Reorganizes tests/docs/ids and updates import ordering. |
| test/unit/test_graph_endpoints_fallback.py | Adds constants, refactors helper naming, and clarifies behavior via assertions. |
| test/unit/test_config_value.py | Adds fixtures/parametrization and broadens behavioral coverage. |
| test/unit/test_card_creator.py | Improves mocking clarity via module path constants and adds docstrings. |
| test/unit/test_add_to_package.py | Large refactor to fixtures/factories; improves readability and removes tempfiles usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| SAMPLE_CSV = ( | ||
| "movie_title,title_year,genres,gross\n" | ||
| '"Monsters,\n Inc.",2001,"Animation|\nComedy",289907418\n' | ||
| '"Monsters, Inc.",2001,Animation|Comedy,289907418\n' | ||
| '"I, Robot",2004,Action|Sci-Fi,144795350\n' | ||
| ) |
Greptile SummaryThis PR refactors 15 unit-test files to follow pytest conventions:
Confidence Score: 5/5All changes are confined to test files with no production code touched; the refactoring is behaviorally equivalent to the prior implementation. No production code is modified. The factory-fixture conversions, import cleanups, and parametrize-id additions preserve the original test logic exactly. The two findings in test_system_context.py are minor: inverted parametrize labels and a singleton reset fixture that only cleans up post-test rather than also pre-test. test/unit/test_system_context.py — inverted parametrize IDs and a non-defensive autouse fixture. Important Files Changed
Reviews (3): Last reviewed commit: "included the root basename" | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3250 +/- ##
=========================================
Coverage ? 28.83%
=========================================
Files ? 381
Lines ? 52467
Branches ? 9260
=========================================
Hits ? 15131
Misses ? 36327
Partials ? 1009 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PR Type
Summary