cirq.testing.EqualsTester

Tests equality against user-provided disjoint equivalence groups.

Methods

add_equality_group

View source

Tries to add a disjoint equivalence group to the equality tester.

This methods asserts that items within the group must all be equal to each other, but not equal to any items in other groups that have been or will be added.

Args
*group_items The items making up the equivalence group.

Raises
AssertionError Items within the group are not equal to each other, or items in another group are equal to items within the new group, or the items violate the equals-implies-same-hash rule.

make_equality_group

View source

Tries to add a disjoint equivalence group to the equality tester.

Uses the factory methods to produce two different objects with the same initialization for each factory. Asserts that the objects are equal, but not equal to any items in other groups that have been or will be added. Adds the objects as a group.

Args
factories Methods for producing independent copies of an item.

Raises
AssertionError The factories produce items not equal to the others, or items in another group are equal to items from the factory, or the items violate the equal-implies-same-hash rule.