v0.11.0
Expressive proto test-assertion layer over the protokit.message differ.
Added
- Expressive message matchers + comparison parity (
protokit.message). A framework-agnostic test-assertion layer over the differ:proto_match(actual, expected, *, partial=, as_set=, ignore=, presence=, approx=)(single-call) andexpect_proto(expected).partially().as_set("items").ignoring(pred).approximately(...).matches(actual)(fluent) raiseAssertionErrorwith the existing per-field diff on mismatch. The same policy is exposed as ahamcrest.BaseMatcherviaequals_proto(...)behind a new optionalprotokit[hamcrest]extra (used asassert_that(actual, equals_proto(...))), and as aproto_matcherpytest fixture; the bareassert msg1 == msg2rich-diff rendering gains presentation-only config. Backing the matcher, theMessageDifferencerengine gains five opt-in, additive capabilities, all targeted by one unified field selector (a dotted path or a(FieldDescriptor, path)predicate): partial / sub-shape scope (set_partial()); keyless set comparison for repeated fields (treat_as_set(selector)); predicate-based field ignore (ignore_fields(...)now also accepts a predicate); EQUAL vs EQUIVALENT presence (set_message_field_comparison(...)); and selective per-field float tolerance (set_float_comparison(..., selector=)). New public surface:proto_match,expect_proto,MatchPolicy,Approx,MatcherError,equals_proto,HamcrestExtraNotInstalledError,MessageFieldComparison. The CLI matcher surface is a separate later effort.
Behavior note: the default EQUIVALENT presence mode now treats a presence-bearing field set to its default value as equal to an unset field (previously a presence difference); a non-default value vs unset is unchanged. Opt into MessageFieldComparison.EQUAL for strict set-vs-unset presence.
Install: pip install protokit==0.11.0 · with the PyHamcrest adapter: pip install 'protokit[hamcrest]==0.11.0'