Utility Classes :: Exact
Overview
The Exact() utility class is used when you want to assert == equality.
In the following signature, the first parameter must be either 6 or 7:
@accepts(IsOneOf(Exact(6), Exact(7)))
Where IsOneOf() is the IsOneOf utility class.
Details
-
The
Exact()constructor accepts only one argument; to supply more or less than this will raise aTypeError. -
If the object being checked by the
Exactinstance does not match, a_TC_ExactErrorwill be raised; thewrongattribute will be the invalid object, therightattribute will be the reference object that was being checked against.This exception is to be caught and converted to a
TypeCheckErrorbefore it reaches the level of the user. -
Exactobjects will only compare equal (i.e.,==) if their reference objects compare equal with==.All
Exactinstances that compare equal with==will produce the same value when run through the built-inhash()function.