Skip to content

Conversation

rongxin-liu
Copy link
Contributor

@rongxin-liu rongxin-liu commented Jul 23, 2025

This PR introduces several improvements and new features to the check50 codebase, focusing on better assertion handling and error reporting.

Assertion Handling Improvements:

  • Introduced the check50/assertions/rewrite.py module, which rewrites assert statements into check50_assert calls. This allows for custom exception handling and better integration with check50's error reporting.
  • Added the check50/assertions/runtime.py module, defining the check50_assert function. This function evaluates conditions, raises appropriate exceptions (Mismatch, Missing, or Failure), and provides detailed context for failed assertions.
  • Integrated the rewrite and rewrite_enabled functions into the main execution flow in check50/__main__.py. If the rewrite feature is enabled, assert statements in check files are replaced with check50_assert calls.

Error Reporting Improvements:

  • Enhanced the Mismatch exception in check50/_api.py to provide more detailed and user-friendly error messages, including truncation logic for long outputs.
  • Introduced a _truncate helper function in check50/_api.py to dynamically truncate strings based on differences with other strings or fixed limits. This improves readability of error messages.
  • International Language Support

@rongxin-liu rongxin-liu marked this pull request as ready for review August 1, 2025 19:08
@rongxin-liu rongxin-liu added this to the 4.0.0 milestone Aug 1, 2025
ivanharvard and others added 22 commits August 1, 2025 17:37
…t; in which builtins were overwritten by context; added tokenization of vars
--assertion-rewrite as an optional flag to override ENABLE_CHECK50_ASSERT
Serialize expected and actual values correctly
Added _process_list as a _raw and _truncate helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Issues relating to check50 4.x enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants