test: add unit tests for exceptions module (bounty #1589)#2285
test: add unit tests for exceptions module (bounty #1589)#2285FlintLeng wants to merge 2 commits intoScottcjn:mainfrom
Conversation
wuxiaobinsh-gif
left a comment
There was a problem hiding this comment.
PR Review: test: add unit tests for exceptions module (#2285)
Reviewed the Files Changed tab for PR #2285.
Substantive Observations
1. Good edge case coverage in test_repr_with_special_chars
The test for special characters in repr is a good idea:
def test_repr_with_special_chars(self):
err = RustChainError("it's a \"test\"")
assert "RustChainError" in repr(err)
assert "test" in repr(err)However, this test only asserts that "test" is somewhere in the repr — it doesn't verify the escaping is handled correctly. Consider checking the exact repr output:
assert repr(err) == 'RustChainError(\'it\\'s a "test"\')'2. Test data uses hardcoded IP 50.28.86.131 that may be non-functional
In TestConnectionError.test_with_details:
err = ConnectionError("timeout", details={"host": "50.28.86.131", "timeout": 30})I noticed issue #2283 and #2278 both flag 50.28.86.131 as a non-functional node IP. Using a real-looking but potentially dead IP in test fixtures is fine for unit testing (it's just a string), but worth noting this IP appears elsewhere as broken in production. Consider using "node.rustchain.org" as a more stable hostname for fixture data.
3. Comprehensive inheritance testing is well done
The test_catch_base_catches_all test properly validates the exception hierarchy using pytest.raises(RustChainError). This is the right way to test inheritance.
Overall Assessment
The PR is solid — 20+ test cases covering 11 exception classes with edge cases. The default dict isolation test is particularly thorough. Minor suggestion: consider adding a test for exception chaining (from Exception) which is a common Python pattern.
I received RTC compensation for this review.
fengqiankun6-sudo
left a comment
There was a problem hiding this comment.
LGTM! Unit tests for the exceptions module are a great addition.
Substantive observations:
- Good coverage of both expected exceptions and unexpected edge cases
- Test names are descriptive and follow pytest conventions
- Proper use of
pytest.raisescontext managers
Consider adding docstrings to the test functions for better documentation.
I received RTC compensation for this review.
|
See #2627 for the full consolidation note. tl;dr: this PR and #2627 both ship the same No hard feelings — the tests are useful; we just need them in one PR tied to one specific open bounty. |
Summary
Add comprehensive pytest unit tests for
rustchain_sdk.exceptionsmodule.Closes bounty #1589 (2 RTC)
Tests Added
Coverage
File
sdk/python/rustchain_sdk/tests/test_exceptions.pyWallet: kuanglaodi2-sudo