expyct.base module

class expyct.base.BaseMatcher

Bases: abc.ABC

Abstract base class from which all matchers inherit.

class expyct.base.Equals(equals: Optional[expyct.base.T] = None)

Bases: Generic[expyct.base.T], expyct.base.BaseMatcher

Mixin for checking equality using a specific object to compare against.

Parameters

equals – the object to check equality with

class expyct.base.Instance(type: Optional[Type] = None, instance_of: Optional[Type] = None)

Bases: expyct.base.BaseMatcher

Match any object that is a class instance.

Parameters
  • type – type of object must equal to given type

  • instance_of – object must be an instance of given type

class expyct.base.MapBefore(map_before: Optional[Callable] = None)

Bases: object

Mixin for applying a function before checking equality.

Parameters

map_before – the mapping function to apply

class expyct.base.Optional(optional: Optional[bool] = None)

Bases: expyct.base.BaseMatcher

Mixin for matching with None.

Parameters

optional – whether None is allowed [default: False]

class expyct.base.Satisfies(satisfies: Optional[Callable[[Any], bool]] = None)

Bases: expyct.base.BaseMatcher

Mixin for checking equality by using a predicate function.

Parameters

satisfies – object must satisfy predicate

class expyct.base.Type(superclass_of: Optional[Type] = None, subclass_of: Optional[Type] = None)

Bases: expyct.base.BaseMatcher

Match any object that is a type.

Parameters
  • superclass_of – the type of which the matched object must be a superclass

  • subclass_of – the type of which the matched object must be a subclass

class expyct.base.Vars(vars: Optional[Any] = None)

Bases: expyct.base.BaseMatcher

Mixin for checking the presence of specific object attributes.

The attributes are compared as a dict. So anything that can be compared with a dict can be used as vars argument, including other expyct objects like expyct.Dict.

Parameters

vars – object attributes (result of vars()) must equal