userver: testsuite.matching.PartialDict Class Reference
Loading...
Searching...
No Matches
testsuite.matching.PartialDict Class Reference

Detailed Description

Partial dictionary matching.

It might be useful to only check specific keys of a dictionary. :py:class:PartialDict serves to solve this task.

:py:class:PartialDict is wrapper around regular dict() when instantiated all arguments are passed as is to internal dict object.

Example:

.. code-block:: python

assert {'foo': 1, 'bar': 2} == matching.PartialDict({

Only check for foo >= 1 ignoring other keys

'foo': matching.Ge(1), })

Definition at line 298 of file matching.py.

Inheritance diagram for testsuite.matching.PartialDict:

Public Member Functions

 __init__ (self, *args, **kwargs)
 __contains__ (self, item)
 __getitem__ (self, item)
 __iter__ (self)
 __len__ (self)
 __repr__ (self)
 __eq__ (self, other)
 __testsuite_visit__ (self, visit)
 __testsuite_resolve_value__ (self, other, report_error)

Protected Attributes

 _dict = dict(*args, **kwargs)

Constructor & Destructor Documentation

◆ __init__()

testsuite.matching.PartialDict.__init__ ( self,
* args,
** kwargs )

Definition at line 319 of file matching.py.

Member Function Documentation

◆ __contains__()

testsuite.matching.PartialDict.__contains__ ( self,
item )

Definition at line 322 of file matching.py.

◆ __eq__()

testsuite.matching.PartialDict.__eq__ ( self,
other )

Definition at line 337 of file matching.py.

◆ __getitem__()

testsuite.matching.PartialDict.__getitem__ ( self,
item )

Definition at line 325 of file matching.py.

◆ __iter__()

testsuite.matching.PartialDict.__iter__ ( self)

Definition at line 328 of file matching.py.

◆ __len__()

testsuite.matching.PartialDict.__len__ ( self)

Definition at line 331 of file matching.py.

◆ __repr__()

testsuite.matching.PartialDict.__repr__ ( self)

Definition at line 334 of file matching.py.

◆ __testsuite_resolve_value__()

testsuite.matching.PartialDict.__testsuite_resolve_value__ ( self,
other,
report_error )

Definition at line 350 of file matching.py.

◆ __testsuite_visit__()

testsuite.matching.PartialDict.__testsuite_visit__ ( self,
visit )

Definition at line 347 of file matching.py.

Member Data Documentation

◆ _dict

testsuite.matching.PartialDict._dict = dict(*args, **kwargs)
protected

Definition at line 320 of file matching.py.


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