caosadvancedtools.tools.test module#
Useful tools for unit or integration tests.
- caosadvancedtools.tools.test.assert_equal_jsons(json1, json2, allow_none: bool = True, allow_empty: bool = True, ignore_datetime: bool = False, ignore_id_value: bool = False, allow_name_dict: bool = False, path: list | None = None) None#
Compare two json objects for near equality.
Raise an assertion exception if they are not equal.
- Parameters:
allow_name_dict (bool, default=False) – If True, a string and a dict
{"name": "string's value"}are considered equal.
- caosadvancedtools.tools.test.compare_workbooks(wb1: Workbook, wb2: Workbook, hidden: bool = True)#
Compare two workbooks for equal content.
Raises an error if differences are found.
- Parameters:
hidden (bool, optional) – Test if the “hidden” status of rows and columns is the same.
- caosadvancedtools.tools.test.equals_with_casting(value1, value2, ignore_datetime: bool = False) bool#
Compare two values, return True if equal, False otherwise. Try to cast to clever datatypes.
- caosadvancedtools.tools.test.purge_from_json(data: dict | list, remove_keys: list[str]) dict | list#
Remove matching entries from json data.
- Parameters:
data (Union[dict, list]) – The json data to clean.
remove_keys (list[str]) – Remove all keys that are in this list
- Returns:
out – The cleaned result.
- Return type:
Union[dict, list]