Skip to content
 
 

Latest commit

 

History

34 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hamcrest-proto

Hamcrest matchers for Protocol Buffers in Python.

This is forked from proto-matcher which was no longer receiving updates and which was itself based on MessageDifferencer and EqualsProto googletest matcher.

API

This packages provides the following proto-related matchers:

equals_proto

equals_proto(expected: Message | str)

Test the argument equals the given protobuf message.

approximately

approximately(matcher: Matcher[Message],
              float_margin: float | None = None,
              float_fraction: float | None = None)

Test the argument equals the given protobuf message, while comparing any float field using approximation.

ignoring_field_paths

ignoring_field_paths(field_paths: set[tuple[str, ...]],
                     matcher: Matcher[Message])

Test the argument equals the given protobuf message, while ignoring those fields specified in the field paths.

ignoring_repeated_field_ordering

ignoring_repeated_field_ordering(matcher: Matcher[Message])

Test the argument equals the given protobuf message, ignoring the ordering of any repeated field.

partially

partially(matcher: Matcher[Message])

Test the argument partially equals the given protobuf message, i.e. if a field is in the argument but not in the expected message, it's ignored in the comparison.

Development

This project uses uv for dependency management and just as a command runner.

just install   # create the venv and generate the test protos
just           # format, run all checks (ruff, pyright, deptry), and test

See the Justfile for individual recipes.

About

Test matchers for https://developers.google.com/protocol-buffers in Python

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages