bundle.testing.tools.assertions

Attributes

Functions

instance_identity(instance, class_type)

Validates that an instance belongs to a specified class or a subclass thereof.

compare(→ None)

Compares two objects for equality and generates a detailed string diff if they differ.

Module Contents

bundle.testing.tools.assertions.LOGGER
bundle.testing.tools.assertions.instance_identity(instance, class_type)[source]

Validates that an instance belongs to a specified class or a subclass thereof.

Asserts that the first argument is an instance and not a class, and that it is an instance of the specified class or its subclass.

Parameters:
  • instance – The object to check.

  • class_type – The class to which the instance should belong.

Raises:

AssertionError – If instance is a class or not an instance of class_type or its subclasses.

bundle.testing.tools.assertions.compare(ref: object, tmp: object) None[source]

Compares two objects for equality and generates a detailed string diff if they differ.

Converts each object to a string and uses difflib to compare these string representations. If differences are found, an AssertionError is raised with a detailed diff.

Parameters:
  • ref – The reference object to compare.

  • tmp – The temporary object to compare against the reference.

Raises:

AssertionError – If ref and tmp are not equal, with a detailed diff as the error message.