test_aide.equality.assert_equal_dispatch¶
- test_aide.equality.assert_equal_dispatch(expected, actual, msg)[source]¶
This function is used to call specific assert functions depending on the input types. Often we are dealing with pandas.DataFrame or pandas.Series objects when asserting equality in this project and these types cannot be compared with the standard ==. This function allows these types to be compared appropriately as well as allowing objects that may contain these pandas types (e.g. list) to also be compared.
The first assert is that actual and expected are of the same type. If this passes then the following types have specific assert functions; - pd.DataFrame - pd.Series - pd.Index - np.NaN - np.ndarray
If the inputs are not of the above types then in the case of the following types; - list - tuple - dict recursive calls will be made on the elements of the object, again according to their tpyes.
Finally if on object is passed that is not one of any of the above types then the standard assert for equality is used.
Note, if pandas or numpy are not available then the types from those libraries will not be considered i.e. if both are not installed then the function will only use the standard equality assertion, while still recursively calling itself if a list, tuple or dict is passed.
- Parameters
actual (object) – The expected object.
expected (object) – The actual object.
msg (string) – A message to be used in the assert, passed onto the specific assert equality function that is called.