userver: testsuite.protobuf.matching.RecursivePartialProtobufDict Class Reference
Loading...
Searching...
No Matches
testsuite.protobuf.matching.RecursivePartialProtobufDict Class Reference

Detailed Description

Recursive partial protobuf matcher.

Compares a protobuf message against an expected dict by converting the message via :py:func:testsuite.protobuf.utils.message_to_dict and delegating to :py:func:testsuite.matching.recursive_partial_dict.

Unlike :py:class:PartialProtobufDict, which only ignores extra fields at the top level, this matcher applies partial matching recursively to every nested message: only the keys listed in the expected dict (at any depth) are checked, and any additional fields on the protobuf message or its nested submessages are ignored.

Example:

.. code-block:: python

Passes regardless of other fields set on msg or on

msg.nested_field, as long as the listed fields match.

assert msg == matching.RecursivePartialProtobufDict({ 'first_name': 'John', 'nested_field': {'inner_field': 1}, })

Definition at line 80 of file matching.py.

Inheritance diagram for testsuite.protobuf.matching.RecursivePartialProtobufDict:

Public Member Functions

 __init__ (self, d)
 __repr__ (self)
 __eq__ (self, other)

Protected Attributes

 _repr = repr
 _impl = impl

Constructor & Destructor Documentation

◆ __init__()

testsuite.protobuf.matching.RecursivePartialProtobufDict.__init__ ( self,
d )

Definition at line 105 of file matching.py.

Member Function Documentation

◆ __eq__()

testsuite.protobuf.matching.ProtobufDictsImpl.__eq__ ( self,
other )
inherited

Definition at line 17 of file matching.py.

◆ __repr__()

testsuite.protobuf.matching.ProtobufDictsImpl.__repr__ ( self)
inherited

Definition at line 14 of file matching.py.

Member Data Documentation

◆ _impl

testsuite.protobuf.matching.ProtobufDictsImpl._impl = impl
protectedinherited

Definition at line 12 of file matching.py.

◆ _repr

testsuite.protobuf.matching.ProtobufDictsImpl._repr = repr
protectedinherited

Definition at line 11 of file matching.py.


The documentation for this class was generated from the following file: