Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dayfine/proto-matcher
Test matchers for https://developers.google.com/protocol-buffers in Python
https://github.com/dayfine/proto-matcher
google matcher matchers protobuf python python3 testing
Last synced: about 1 month ago
JSON representation
Test matchers for https://developers.google.com/protocol-buffers in Python
- Host: GitHub
- URL: https://github.com/dayfine/proto-matcher
- Owner: dayfine
- License: apache-2.0
- Created: 2020-07-01T07:39:33.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-28T22:46:17.000Z (about 1 year ago)
- Last Synced: 2024-10-05T21:46:01.489Z (about 1 month ago)
- Topics: google, matcher, matchers, protobuf, python, python3, testing
- Language: Python
- Homepage:
- Size: 36.1 KB
- Stars: 5
- Watchers: 3
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# proto-matcher
Test matchers for Protobuffer in Python.
This is based on [MessageDifferencer](https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.util.message_differencer) as well as the [EqualsProto](https://github.com/google/googletest/issues/1761) googletest matcher.
## API
This packages provides the following [PyHamcrest](https://github.com/hamcrest/PyHamcrest) matchers:
### `equals_proto`
```python
equals_proto(message: Union[Message, str])
```
Test the argument equals the given protobuf message.### `approximately`
```python
approximately(proto_matcher: Matcher[Message],
float_margin: Optional[float] = None,
float_fraction: Optional[float] = None)
```
Test the argument equals the given protobuf message, while comparing any float field using approximation.### `ignoring_field_paths`
```python
ignoring_field_paths(field_paths: Set[Tuple[str]],
matcher: _ProtoMatcher)
```
Test the argument equals the given protobuf message, while ignoring those fields specified in the field paths.### `ignoring_repeated_field_ordering`
```python
ignoring_repeated_field_ordering(proto_matcher: Matcher[Message])
```
Test the argument equals the given protobuf message, ignoring the ordering of any repeated field.### `partially`
```python
partially(proto_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 comparsion.