assertionlib.manager

A module containing the actual AssertionManager class.

Index

assertion

An instance of AssertionManager.

AssertionManager(repr_instance)

A class for performing assertions and providing informative exception messages.

AssertionManager.assert_(func, *args[, ...])

Perform the following assertion: assert func(*args, **kwargs).

AssertionManager.__call__(value, *[, ...])

Equivalent to assert value.

AssertionManager.add_to_instance(func[, ...])

Add a new custom assertion method to this instance.

Assertions based on the builtin operator module.

AssertionManager.abs

Perform the following assertion: assert abs(a).

AssertionManager.add

Perform the following assertion: assert add(a, b).

AssertionManager.and_

Perform the following assertion: assert and_(a, b).

AssertionManager.concat

Perform the following assertion: assert concat(a, b).

AssertionManager.contains

Perform the following assertion: assert contains(a, b).

AssertionManager.countOf

Perform the following assertion: assert countOf(a, b).

AssertionManager.eq

Perform the following assertion: assert eq(a, b).

AssertionManager.floordiv

Perform the following assertion: assert floordiv(a, b).

AssertionManager.ge

Perform the following assertion: assert ge(a, b).

AssertionManager.getitem

Perform the following assertion: assert getitem(a, b).

AssertionManager.gt

Perform the following assertion: assert gt(a, b).

AssertionManager.index

Perform the following assertion: assert index(a).

AssertionManager.indexOf

Perform the following assertion: assert indexOf(a, b).

AssertionManager.inv

Perform the following assertion: assert inv(a).

AssertionManager.invert

Perform the following assertion: assert invert(a).

AssertionManager.is_

Perform the following assertion: assert is_(a, b).

AssertionManager.is_not

Perform the following assertion: assert is_not(a, b).

AssertionManager.le

Perform the following assertion: assert le(a, b).

AssertionManager.lshift

Perform the following assertion: assert lshift(a, b).

AssertionManager.lt

Perform the following assertion: assert lt(a, b).

AssertionManager.matmul

Perform the following assertion: assert matmul(a, b).

AssertionManager.mod

Perform the following assertion: assert mod(a, b).

AssertionManager.mul

Perform the following assertion: assert mul(a, b).

AssertionManager.ne

Perform the following assertion: assert ne(a, b).

AssertionManager.neg

Perform the following assertion: assert neg(a).

AssertionManager.not_

Perform the following assertion: assert not_(a).

AssertionManager.or_

Perform the following assertion: assert or_(a, b).

AssertionManager.pos

Perform the following assertion: assert pos(a).

AssertionManager.pow

Perform the following assertion: assert pow(a, b).

AssertionManager.rshift

Perform the following assertion: assert rshift(a, b).

AssertionManager.sub

Perform the following assertion: assert sub(a, b).

AssertionManager.truediv

Perform the following assertion: assert truediv(a, b).

AssertionManager.truth

Perform the following assertion: assert truth(a).

AssertionManager.length_hint

Perform the following assertion: assert length_hint(obj, default=default).

Assertions based on the builtin os.path module.

AssertionManager.isabs

Perform the following assertion: assert isabs(s).

AssertionManager.isdir

Perform the following assertion: assert isdir(s).

AssertionManager.isfile

Perform the following assertion: assert isfile(path).

AssertionManager.islink

Perform the following assertion: assert islink(path).

AssertionManager.ismount

Perform the following assertion: assert ismount(path).

Assertions based on the builtin math module.

AssertionManager.allclose

Perform the following assertion: assert isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol).

AssertionManager.isclose

Perform the following assertion: assert isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol).

AssertionManager.isfinite

Perform the following assertion: assert isfinite(x).

AssertionManager.isinf

Perform the following assertion: assert isinf(x).

AssertionManager.isnan

Perform the following assertion: assert isnan(x).

Assertions based on the builtin builtins module.

AssertionManager.callable

Perform the following assertion: assert callable(obj).

AssertionManager.hasattr

Perform the following assertion: assert hasattr(obj, name).

AssertionManager.isinstance

Perform the following assertion: assert isinstance(obj, class_or_tuple).

AssertionManager.issubclass

Perform the following assertion: assert issubclass(cls, class_or_tuple).

AssertionManager.len

Perform the following assertion: assert len(obj).

AssertionManager.any

Perform the following assertion: assert any(iterable).

AssertionManager.all

Perform the following assertion: assert all(iterable).

AssertionManager.isdisjoint

Perform the following assertion: assert isdisjoint(a, b).

AssertionManager.issuperset

Perform the following assertion: assert issuperset(a, b).

AssertionManager.issubset

Perform the following assertion: assert issubset(a, b).

AssertionManager.round

Perform the following assertion: assert round(number, ndigits=ndigits).

Miscellaneous assertions.

AssertionManager.len_eq

Perform the following assertion: assert len_eq(a, b).

AssertionManager.str_eq

Perform the following assertion: assert str_eq(a, b, str_converter=str_converter).

AssertionManager.shape_eq

Perform the following assertion: assert shape_eq(a, b).

AssertionManager.function_eq

Perform the following assertion: assert function_eq(func1, func2).

API

assertionlib.manager.assertion : AssertionManager

An instance of AssertionManager.

class assertionlib.manager.AssertionManager(repr_instance: ~typing.Optional[~reprlib.Repr] = <assertionlib.ndrepr.NDRepr object>)[source]

A class for performing assertions and providing informative exception messages.

A number of usage examples are provided in the the documentation.

Parameters:

repr_instance (reprlib.Repr, optional) – An instance of reprlib.Repr for formatting Exception messages. The passed instance should have access to a bound callable by the name of repr, which in turn should produce a string representation of any passed objects. If None, default the builtin repr() function. See also AssertionManager.repr_instance.

repr_instance

An instance of reprlib.Repr for formatting Exception messages. The passed instance should have access to a bound callable by the name of repr, which in turn should produce a string representation of passed objects. If None, default the builtin repr() function.

Type:

reprlib.Repr, optional

repr_fallback

A fallback value in case AssertionManager.repr_instance is None.

Type:

Callable[[Any], str]

maxstring_fallback

A fallback value in case AssertionManager.repr_instance is None.

Type:

int

AssertionManager.assert_(func: Callable[[...], T], *args: Any, invert: bool = False, exception: Optional[Type[Exception]] = None, post_process: Optional[Callable[[T], Any]] = None, message: Optional[str] = None, **kwargs: Any) None[source]

Perform the following assertion: assert func(*args, **kwargs).

Examples

For example assert 5 == 5 is equivalent to AssertionManager().assert_(operator.eq, 5, 5).

Parameters:
  • func (Callable[..., T]) – The callable whose output will be evaluated.

  • *args (Any) – Positional arguments for func.

Keyword Arguments:
  • invert (bool, optional) – If True, invert the output of the assertion: assert not func(*args, **kwargs).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation. The only dissalowed value is AssertionError.

  • post_process (Callable[[T], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example functions would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

  • **kwargs (Any, optional) – Keyword arguments for func.

Return type:

None

See also

AssertionManager.__call__()

Equivalent to assert value.

AssertionManager.__call__(value: T, *, invert: bool = False, post_process: Optional[Callable[[T], Any]] = None, message: Optional[str] = None) None[source]

Equivalent to assert value.

Examples

>>> from assertionlib import assertion

>>> assertion(5 == 5)
>>> assertion(5 == 6)
Traceback (most recent call last):
    ...
AssertionError: output = (value); assert output

exception: AssertionError = 'None'

output: bool = False
value: bool = False
Parameters:

value (T) – The to-be asserted value.

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not value.

  • post_process (Callable[[T], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example functions would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

AssertionManager.add_to_instance(func: Callable, name: Optional[str] = None, override_attr: bool = False) None[source]

Add a new custom assertion method to this instance.

The new method name is added to AssertionManager._PRIVATE_ATTR.

Parameters:

func (Callable) – The callable whose output will be asserted in the to-be created method.

Keyword Arguments:
  • name (str, optional) – The name of the new method. If None, use the name of func.

  • override_attr (bool) – If False, raise an AttributeError if a method with the same name already exists in this instance.

Return type:

None

Raises:

AttributeError – Raised if override_attr=False and a method with the same name already exists in this instance.

Assertions based on the builtin operator module

AssertionManager.abs(a, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert abs(a).

Parameters:

a – The positional-only argument a of abs().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not abs(a).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

abs()

Same as abs(a).

AssertionManager.add(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert add(a, b).

Parameters:
  • a – The positional-only argument a of add().

  • b – The positional-only argument b of add().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not add(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

add()

Same as a + b.

AssertionManager.and_(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert and_(a, b).

Parameters:
  • a – The positional-only argument a of and_().

  • b – The positional-only argument b of and_().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not and_(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

and_()

Same as a & b.

AssertionManager.concat(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert concat(a, b).

Parameters:
  • a – The positional-only argument a of concat().

  • b – The positional-only argument b of concat().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not concat(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

concat()

Same as a + b, for a and b sequences.

AssertionManager.contains(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert contains(a, b).

Parameters:
  • a – The positional-only argument a of contains().

  • b – The positional-only argument b of contains().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not contains(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

contains()

Same as b in a (note reversed operands).

AssertionManager.countOf(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert countOf(a, b).

Parameters:
  • a – The positional-only argument a of countOf().

  • b – The positional-only argument b of countOf().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not countOf(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

countOf()

Return the number of times b occurs in a.

AssertionManager.eq(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert eq(a, b).

Parameters:
  • a – The positional-only argument a of eq().

  • b – The positional-only argument b of eq().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not eq(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

eq()

Same as a == b.

AssertionManager.floordiv(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert floordiv(a, b).

Parameters:
  • a – The positional-only argument a of floordiv().

  • b – The positional-only argument b of floordiv().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not floordiv(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

floordiv()

Same as a // b.

AssertionManager.ge(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert ge(a, b).

Parameters:
  • a – The positional-only argument a of ge().

  • b – The positional-only argument b of ge().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not ge(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

ge()

Same as a >= b.

AssertionManager.getitem(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert getitem(a, b).

Parameters:
  • a – The positional-only argument a of getitem().

  • b – The positional-only argument b of getitem().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not getitem(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

getitem()

Same as a[b].

AssertionManager.gt(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert gt(a, b).

Parameters:
  • a – The positional-only argument a of gt().

  • b – The positional-only argument b of gt().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not gt(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

gt()

Same as a > b.

AssertionManager.index(a, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert index(a).

Parameters:

a – The positional-only argument a of index().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not index(a).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

index()

Same as a.__index__()

AssertionManager.indexOf(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert indexOf(a, b).

Parameters:
  • a – The positional-only argument a of indexOf().

  • b – The positional-only argument b of indexOf().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not indexOf(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

indexOf()

Return the first index of b in a.

AssertionManager.inv(a, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert inv(a).

Parameters:

a – The positional-only argument a of inv().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not inv(a).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

inv()

Same as ~a.

AssertionManager.invert(a, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert invert(a).

Parameters:

a – The positional-only argument a of invert().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not invert(a).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

invert()

Same as ~a.

AssertionManager.is_(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert is_(a, b).

Parameters:
  • a – The positional-only argument a of is_().

  • b – The positional-only argument b of is_().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not is_(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

is_()

Same as a is b.

AssertionManager.is_not(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert is_not(a, b).

Parameters:
  • a – The positional-only argument a of is_not().

  • b – The positional-only argument b of is_not().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not is_not(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

is_not()

Same as a is not b.

AssertionManager.le(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert le(a, b).

Parameters:
  • a – The positional-only argument a of le().

  • b – The positional-only argument b of le().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not le(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

le()

Same as a <= b.

AssertionManager.lshift(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert lshift(a, b).

Parameters:
  • a – The positional-only argument a of lshift().

  • b – The positional-only argument b of lshift().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not lshift(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

lshift()

Same as a << b.

AssertionManager.lt(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert lt(a, b).

Parameters:
  • a – The positional-only argument a of lt().

  • b – The positional-only argument b of lt().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not lt(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

lt()

Same as a < b.

AssertionManager.matmul(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert matmul(a, b).

Parameters:
  • a – The positional-only argument a of matmul().

  • b – The positional-only argument b of matmul().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not matmul(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

matmul()

Same as a @ b.

AssertionManager.mod(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert mod(a, b).

Parameters:
  • a – The positional-only argument a of mod().

  • b – The positional-only argument b of mod().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not mod(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

mod()

Same as a % b.

AssertionManager.mul(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert mul(a, b).

Parameters:
  • a – The positional-only argument a of mul().

  • b – The positional-only argument b of mul().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not mul(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

mul()

Same as a * b.

AssertionManager.ne(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert ne(a, b).

Parameters:
  • a – The positional-only argument a of ne().

  • b – The positional-only argument b of ne().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not ne(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

ne()

Same as a != b.

AssertionManager.neg(a, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert neg(a).

Parameters:

a – The positional-only argument a of neg().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not neg(a).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

neg()

Same as -a.

AssertionManager.not_(a, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert not_(a).

Parameters:

a – The positional-only argument a of not_().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not not_(a).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

not_()

Same as not a.

AssertionManager.or_(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert or_(a, b).

Parameters:
  • a – The positional-only argument a of or_().

  • b – The positional-only argument b of or_().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not or_(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

or_()

Same as a | b.

AssertionManager.pos(a, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert pos(a).

Parameters:

a – The positional-only argument a of pos().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not pos(a).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

pos()

Same as +a.

AssertionManager.pow(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert pow(a, b).

Parameters:
  • a – The positional-only argument a of pow().

  • b – The positional-only argument b of pow().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not pow(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

pow()

Same as a ** b.

AssertionManager.rshift(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert rshift(a, b).

Parameters:
  • a – The positional-only argument a of rshift().

  • b – The positional-only argument b of rshift().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not rshift(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

rshift()

Same as a >> b.

AssertionManager.sub(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert sub(a, b).

Parameters:
  • a – The positional-only argument a of sub().

  • b – The positional-only argument b of sub().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not sub(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

sub()

Same as a - b.

AssertionManager.truediv(a, b, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert truediv(a, b).

Parameters:
  • a – The positional-only argument a of truediv().

  • b – The positional-only argument b of truediv().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not truediv(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

truediv()

Same as a / b.

AssertionManager.truth(a, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert truth(a).

Parameters:

a – The positional-only argument a of truth().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not truth(a).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

truth()

Return True if a is true, False otherwise.

AssertionManager.length_hint(obj, default=0, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert length_hint(obj, default=default).

Parameters:
Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not length_hint(obj, default=default).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

length_hint()

Return an estimate of the number of items in obj. This is useful for presizing containers when building from an iterable. If the object supports len(), the result will be exact. Otherwise, it may over- or under-estimate by an arbitrary amount. The result will be an integer >= 0.

Assertions based on the builtin os.path module

AssertionManager.isabs(s, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert isabs(s).

Parameters:

s – The positional-only argument s of isabs().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isabs(s).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isabs()

Test whether a path is absolute

AssertionManager.isdir(s, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert isdir(s).

Parameters:

s – The positional-only argument s of isdir().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isdir(s).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isdir()

Return true if the pathname refers to an existing directory.

AssertionManager.isfile(path, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert isfile(path).

Parameters:

path – The positional-only argument path of isfile().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isfile(path).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isfile()

Test whether a path is a regular file

Perform the following assertion: assert islink(path).

Parameters:

path – The positional-only argument path of islink().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not islink(path).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

islink()

Test whether a path is a symbolic link

AssertionManager.ismount(path, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert ismount(path).

Parameters:

path – The positional-only argument path of ismount().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not ismount(path).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

ismount()

Test whether a path is a mount point

Assertions based on the builtin math module

AssertionManager.allclose(a, b, /, *, rel_tol=1e-09, abs_tol=0.0, **kwargs: ~typing.Any) None

Perform the following assertion: assert isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol).

Parameters:
  • a – The positional-only argument a of isclose().

  • b – The positional-only argument b of isclose().

  • rel_tol – The keyword-only argument rel_tol of isclose().

  • abs_tol – The keyword-only argument abs_tol of isclose().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isclose()

Determine whether two floating point numbers are close in value. rel_tol maximum difference for being considered “close”, relative to the magnitude of the input values abs_tol maximum difference for being considered “close”, regardless of the magnitude of the input values Return True if a is close in value to b, and False otherwise. For the values to be considered close, the difference between them must be smaller than at least one of the tolerances. -inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is not close to anything, even itself. inf and -inf are only close to themselves.

AssertionManager.isclose(a, b, /, *, rel_tol=1e-09, abs_tol=0.0, **kwargs: ~typing.Any) None

Perform the following assertion: assert isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol).

Parameters:
  • a – The positional-only argument a of isclose().

  • b – The positional-only argument b of isclose().

  • rel_tol – The keyword-only argument rel_tol of isclose().

  • abs_tol – The keyword-only argument abs_tol of isclose().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isclose()

Determine whether two floating point numbers are close in value. rel_tol maximum difference for being considered “close”, relative to the magnitude of the input values abs_tol maximum difference for being considered “close”, regardless of the magnitude of the input values Return True if a is close in value to b, and False otherwise. For the values to be considered close, the difference between them must be smaller than at least one of the tolerances. -inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is not close to anything, even itself. inf and -inf are only close to themselves.

AssertionManager.isfinite(x, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert isfinite(x).

Parameters:

x – The positional-only argument x of isfinite().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isfinite(x).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isfinite()

Return True if x is neither an infinity nor a NaN, and False otherwise.

AssertionManager.isinf(x, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert isinf(x).

Parameters:

x – The positional-only argument x of isinf().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isinf(x).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isinf()

Return True if x is a positive or negative infinity, and False otherwise.

AssertionManager.isnan(x, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert isnan(x).

Parameters:

x – The positional-only argument x of isnan().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isnan(x).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isnan()

Return True if x is a NaN (not a number), and False otherwise.

Assertions based on the builtin builtins module

AssertionManager.callable(obj, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert callable(obj).

Parameters:

obj – The positional-only argument obj of callable().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not callable(obj).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

callable()

Return whether the object is callable (i.e., some kind of function).

Note that classes are callable, as are instances of classes with a __call__() method.

AssertionManager.hasattr(obj, name, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert hasattr(obj, name).

Parameters:
  • obj – The positional-only argument obj of hasattr().

  • name – The positional-only argument name of hasattr().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not hasattr(obj, name).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

hasattr()

Return whether the object has an attribute with the given name.

This is done by calling getattr(obj, name) and catching AttributeError.

AssertionManager.isinstance(obj, class_or_tuple, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert isinstance(obj, class_or_tuple).

Parameters:
  • obj – The positional-only argument obj of isinstance().

  • class_or_tuple – The positional-only argument class_or_tuple of isinstance().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isinstance(obj, class_or_tuple).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isinstance()

Return whether an object is an instance of a class or of a subclass thereof.

A tuple, as in isinstance(x, (A, B, ...)), may be given as the target to check against. This is equivalent to isinstance(x, A) or isinstance(x, B) or ... etc.

AssertionManager.issubclass(cls, class_or_tuple, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert issubclass(cls, class_or_tuple).

Parameters:
  • cls – The positional-only argument cls of issubclass().

  • class_or_tuple – The positional-only argument class_or_tuple of issubclass().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not issubclass(cls, class_or_tuple).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

issubclass()

Return whether ‘cls’ is a derived from another class or is the same class.

A tuple, as in issubclass(x, (A, B, ...)), may be given as the target to check against. This is equivalent to issubclass(x, A) or issubclass(x, B) or ... etc.

AssertionManager.len(obj, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert len(obj).

Parameters:

obj – The positional-only argument obj of len().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not len(obj).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

len()

Return the number of items in a container.

AssertionManager.any(iterable, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert any(iterable).

Parameters:

iterable – The positional-only argument iterable of any().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not any(iterable).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

any()

Return True if bool(x) is True for any x in the iterable.

If the iterable is empty, return False.

AssertionManager.all(iterable, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert all(iterable).

Parameters:

iterable – The positional-only argument iterable of all().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not all(iterable).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

all()

Return True if bool(x) is True for all values x in the iterable.

If the iterable is empty, return True.

AssertionManager.isdisjoint(a: ~typing.Iterable[~typing.Hashable], b: ~typing.Iterable[~typing.Hashable], /, **kwargs: ~typing.Any) None

Perform the following assertion: assert isdisjoint(a, b).

Parameters:
Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not isdisjoint(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

isdisjoint()

Check if a has no elements in b.

AssertionManager.issuperset(a: ~typing.Iterable[~typing.Hashable], b: ~typing.Iterable[~typing.Hashable], /, **kwargs: ~typing.Any) None

Perform the following assertion: assert issuperset(a, b).

Parameters:
Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not issuperset(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

issuperset()

Check if a contains all elements from b.

AssertionManager.issubset(a: ~typing.Iterable[~typing.Hashable], b: ~typing.Iterable[~typing.Hashable], /, **kwargs: ~typing.Any) None

Perform the following assertion: assert issubset(a, b).

Parameters:
  • a – The positional-only argument a of issubset().

  • b – The positional-only argument b of issubset().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not issubset(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

issubset()

Check if b contains all elements in a.

AssertionManager.round(number, /, *, ndigits=None, **kwargs: ~typing.Any) None

Perform the following assertion: assert round(number, ndigits=ndigits).

Parameters:
  • number – The positional-only argument number of round().

  • ndigits – The keyword-only argument ndigits of round().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not round(number, ndigits=ndigits).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

round()

Round a number to a given precision in decimal digits.

The return value is an integer if ndigits is omitted or None. Otherwise the return value has the same type as the number. ndigits may be negative.

Miscellaneous assertions

AssertionManager.len_eq(a: ~typing.Sized, b: int, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert len_eq(a, b).

Parameters:
  • a – The positional-only argument a of len_eq().

  • b – The positional-only argument b of len_eq().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not len_eq(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

len_eq()

Check if the length of a is equivalent to b: len(a) == b.

AssertionManager.str_eq(a: ~assertionlib.assertion_functions.T, b: str, /, *, str_converter: ~typing.Callable[[~assertionlib.assertion_functions.T], str] = <built-in function repr>, **kwargs: ~typing.Any) None

Perform the following assertion: assert str_eq(a, b, str_converter=str_converter).

Parameters:
  • a – The positional-only argument a of str_eq().

  • b – The positional-only argument b of str_eq().

  • str_converter – The keyword-only argument str_converter of str_eq().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not str_eq(a, b, str_converter=str_converter).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

str_eq()

Check if the string-representation of a is equivalent to b: repr(a) == b.

AssertionManager.shape_eq(a: ndarray[Any, Any], b: ~typing.Union[ndarray[Any, Any], ~typing.Tuple[int, ...]], /, **kwargs: ~typing.Any) None

Perform the following assertion: assert shape_eq(a, b).

Parameters:
  • a – The positional-only argument a of shape_eq().

  • b – The positional-only argument b of shape_eq().

Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not shape_eq(a, b).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

shape_eq()

Check if the shapes of a and b are equivalent: a.shape == getattr(b, 'shape', b). b should be either an object with the shape attribute (e.g. a NumPy array) or a tuple representing a valid array shape.

AssertionManager.function_eq(func1: function, func2: function, /, **kwargs: ~typing.Any) None

Perform the following assertion: assert function_eq(func1, func2).

Parameters:
Keyword Arguments:
  • invert (bool) – If True, invert the output of the assertion: assert not function_eq(func1, func2).

  • exception (type [Exception], optional) – Assert that exception is raised during/before the assertion operation.

  • post_process (Callable[[Any], bool], optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes of any() and all().

  • message (str, optional) – A custom error message to-be passed to the assert statement.

Return type:

None

See also

function_eq()

Check if two functions are equivalent by checking if their __code__ is identical. func1 and func2 should be instances of FunctionType or any other object with access to the __code__ attribute.