def test__one_layer_tree(): def foo(stuff): return stuff tree_func = one_layer_tree(foo, smpl_1, smpl_2, smpl_3) res = tree_func('monkey') assert(res['smpl_1'] == tuple(['monkey_one'])) assert(res['smpl_2'] == tuple(['monkey_two'])) assert(res['smpl_3'] == tuple(['monkey_three']))
def test__one_layer_tree__two(): def foo(stuff): return stuff tree_func = one_layer_tree(foo, smpl_1, smpl_2, smpl_3) assert(tree_func.functors[0].__name__ == 'foo') assert(tree_func.functors[1][0].__name__ == 'smpl_1') assert(tree_func.functors[1][1].__name__ == 'smpl_2') assert(tree_func.functors[1][2].__name__ == 'smpl_3')
def layer_tree_one__frst_split_period__then_rplc_t__other_rplc_r(txt): rm_t = partial(rm_char, char='t') rm_t_split = preiter_iter_postiter(iter_func=spliter, post_iter=rm_t) rm_t_split.__name__ = 'rm_t_split' rm_r = partial(rm_char, char='r') rm_r_split = preiter_iter_postiter(iter_func=spliter, post_iter=rm_r) rm_r_split.__name__ = 'rm_r_split' func = one_layer_tree(split_on, *[rm_t_split, rm_r_split]) return func(txt)