Skip to content

test: add round-trip tests for collections and structs#108

Merged
davidhewitt merged 1 commit intodavidhewitt:mainfrom
leftygbalogh:lefty/tests-core-round-trips
Apr 14, 2026
Merged

test: add round-trip tests for collections and structs#108
davidhewitt merged 1 commit intodavidhewitt:mainfrom
leftygbalogh:lefty/tests-core-round-trips

Conversation

@leftygbalogh
Copy link
Copy Markdown
Contributor

Summary

Adds explicit table-driven round-trip tests for collection types and structs, covering gaps in the current upstream test suite.

Files added

** ests/test_collections.rs** (18 tests)

  • Vec round-trips for i32, f64, String, bool
  • Empty Vec round-trip to empty Vec (not None)
  • Tuple characterisation: (A, B) Python representation observed and asserted
  • HashMap<String, V> content equality (no order assertion)
  • BTreeMap<String, V> ordering and content equality

** ests/test_structs.rs** (12 tests)

  • Basic struct round-trip
  • #[serde(rename)] — renamed key present in Python dict, original absent
  • #[serde(rename_all = "camelCase")] — all keys renamed
  • Unknown fields default behaviour — silently ignored, no panic
  • #[serde(deny_unknown_fields)] — returns Err
  • Option None and Some variants both round-trip correctly

Test approach

Plain #[test] functions using Python::attach. No new dev-dependencies. All tests pass with cargo test, cargo test --features pyo3/abi3-py37, and cargo test --features arbitrary_precision.

tests/test_collections.rs (18 tests): Vec<T>, HashMap, BTreeMap, tuples
tests/test_structs.rs (12 tests): structs, serde rename, Option<T>, deny_unknown_fields
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.49%. Comparing base (0085a18) to head (4b76820).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #108      +/-   ##
==========================================
+ Coverage   84.48%   85.49%   +1.01%     
==========================================
  Files           3        3              
  Lines        1186     1186              
  Branches     1186     1186              
==========================================
+ Hits         1002     1014      +12     
+ Misses        118      106      -12     
  Partials       66       66              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Owner

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@davidhewitt davidhewitt merged commit 991f3f5 into davidhewitt:main Apr 14, 2026
34 checks passed
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.

2 participants