Skip to content

test: assert unwrapped values in elementary_test and unwrap tests - #605

Open
Jalst wants to merge 1 commit into
python-poetry:masterfrom
Jalst:test/unwrap-value-assertions
Open

Jalst wants to merge 1 commit into
python-poetry:masterfrom
Jalst:test/unwrap-value-assertions

Conversation

@Jalst

@Jalst Jalst commented Sep 17, 2026

Copy link
Copy Markdown

Summary

Related to #603.

As noted in #603, tests/util.py::elementary_test previously only asserted isinstance(v.unwrap(), unwrapped_type). Consequently, the test_*_unwrap tests in tests/test_items.py could detect type errors, but not value corruptions (e.g. Bool.unwrap returning not bool(self) would still pass both test_true_unwrap and test_false_unwrap).

This PR closes that testing gap:

  • Adds an optional expected parameter to elementary_test (defaulting to a sentinel _DEFAULT = object()), asserting v_unwrapped == expected when provided.
  • Passes the expected pure Python value across all item unwrap unit tests (int, float, bool, datetime, str, None, time, date).
  • Adds value equality assertions to test_aot_unwrap, test_array_unwrap, and test_abstract_table_unwrap in tests/test_items.py.
  • Adds value equality assertion to test_toml_document_unwrap in tests/test_toml_document.py.

Verification

  • pytest tests: 1,058 passed.
  • Pre-commit hooks (trailing-whitespace, end-of-file-fixer, pyupgrade, ruff, ruff-format): all passed.
  • Verified mutation sensitivity: deliberately returning a corrupted unwrapped value fails the test suite as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant