Repository navigation
fix: add messages to functional assertions - #151
SwetaKumari7 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
@coderabbitai review Hi, could you please review this PR when you get a chance? I've added actionable messages to the functional assertions while preserving the existing assertion logic and order. Thank you for your time and feedback! |
✅ Action performedReview finished.
|
abhiksark
left a comment
There was a problem hiding this comment.
Not ready to merge at 9160845. Four added message expressions re-run learner code: square(0), absolute(0), absolute(-100), and apply_twice(..., 0). All four were reproduced with a side-effecting failing learner function; the message masks the original assertion with RuntimeError. Please use expected-value messages without re-evaluation and add regression coverage.
The head branch is also improve-assertion-messages; the repository requires a fix/ or feature/ branch targeting dev. Please use a compliant branch and apply the file-location-comment and 80-column conventions. After correcting these issues, record the required full-suite, fixture-verification, and packaging checks and obtain passing CI. Issue #86 remains open. Full build/runtime validation was not repeated here because the reproduced message defect and branch-policy mismatch already block merging.
| assert square(3) == 9, f"square(3) should be 9, got {square(3)}" | ||
| assert square(5) == 25, f"square(5) should be 25, got {square(5)}" | ||
| assert square(0) == 0 | ||
| assert square(0) == 0, f"square(0) should be 0, got {square(0)}" |
There was a problem hiding this comment.
[P2] Do not call the learner's function again in the failure message.
The new square(0) message evaluates square(0) a second time. I reproduced this with a learner function that returns an incorrect result on the first zero call and raises on the second: the check reports the second call's RuntimeError instead of the expected assertion failure. This violates CONTRIBUTING.md's rule against re-calling learner functions to format messages.
Use a constant expected-value message here. The new absolute(0) and absolute(-100) messages in functional2 have the same problem. Add a focused regression using a side-effecting failing function.
| print("functional6 ✓") | ||
| assert apply_twice(lambda x: x + 1, 0) == 2, ( | ||
| f"apply_twice(lambda x: x + 1, 0) should be 2, " | ||
| f"got {apply_twice(lambda x: x + 1, 0)}" |
There was a problem hiding this comment.
[P2] Preserve the single evaluation of apply_twice.
This new failure message also calls apply_twice(...) again, including executing the learner's callback again. The same probe reproduces a RuntimeError masking the original assertion failure. Keep the original predicate and use an expected-value message that does not execute learner code.
|
Completed with contributor credit in #169, now squash-merged into dev as |
Summary
Verification
python -m pytest tests/integration/test_solution_verify.py -qpythonlings --root tests/fixtures/passing_curriculum verifygit diff --checkpasses.Closes #86
Thank you for reviewing this contribution. Any feedback or suggestions are welcome.
Summary by CodeRabbit