Skip to content

Container matchers

DictContainingKeys

Matches any dictionary containing at least all the given keys. Additional items are ignored.

Parameters:

Name Type Description Default
keys set

set of keys to match

required

DictContainingValues

Matches any dictionary containing all the given values

Parameters:

Name Type Description Default
values list

list of values to match

required

DictContainingItems

Matches any dictionary containing all the given items, where an item is a key-value pair.

Parameters:

Name Type Description Default
items dict

dict of items to match

required

ListContaining

Matches any list containing at least all the given items in any order. Additional items are ignored.

Compare with [ListContainingOnly][ListContainingOnly].

Parameters:

Name Type Description Default
items list

items to check for

required

ListContainingOnly

Matches a list, if and only if it contains all of the given items, in any order, and no additional items.

Compare with [ListContaining][ListContaining].

Parameters:

Name Type Description Default
items list

the expected items.

required

ListOfLength

Matches any list of a given length

Parameters:

Name Type Description Default
length int

the expected length of the list

required

Raises:

Type Description
ValueError

length is < 0

SetContaining

Matches any set containing at least all the given items. Additional items are ignored.

Parameters:

Name Type Description Default
items set

items to check for

required

ObjectContainingProperties

Matches any object containing all the given properties. Note that this does not check property values - just the presence of those properties.

Parameters:

Name Type Description Default
properties set

set of properties to match

required

ObjectContainingItems

Matches any object containing all the given items, where an item is a property-value pair.

Parameters:

Name Type Description Default
items dict

dict of items to match

required