def any_test_treeEvaluation(tree, expect, file_name=None): if file_name is not None and tree is None: if file_name.startswith('AND'): dir = 'test_data_and' elif file_name.startswith('OR'): dir = 'test_data_or' elif file_name.startswith('XOR'): dir = 'test_data_xor' elif file_name.startswith('ONE'): dir = 'test_data_one' else: dir = 'test_data_NONE' src = 'test_data/' + dir + '/' + file_name data = dict() with open(get_src(src), "r") as f: data = json.load(f) assert restore_dict_to_tree(data).evaluate_tree() == expect else: assert tree.evaluate_tree() == expect
def any_test_dict_to_tree(dict_of_tree): treedict_of_tree = restore_dict_to_tree(dict_of_tree) assert treedict_of_tree.save_tree_to_dict() == dict_of_tree