f = get_nodes.mmnode_plus.parse_node_text states = ('ignore', 'ignore_all', 'ignore_children') tests = (('hello', ()), ('hello (i)', ('ignore', )), ('hello (ic)', ('ignore_children', )), ('hello (ia)', ('ignore_all', )), ('school principal interview after leaving (ic) (m: magnet)', ('ignore_children', ))) for test in tests: result = f(test[0]) for state in states: test_factory( state in test[1], result.get(state) or False, "Unexpected %s for state %s on input %s" % (result.get(state), state, test[0])) root = get_nodes.mmnode_plus.factory('testmap.mm') test_factory('lie to me', root.ultimate_parent().text) tests = [ (root, { 'skip_traversal': False, 'skip_as_child': True, 'skip_as_parent': False, 'is_leaf': False }), (root[0], {
(root[2][1], root[2][2], False), (root[2][2], root[2][0], False), (root[6][0], root[6][1], True), (root[6][2], root[6][3], True), (root[6][2], root[6][4], True), (root[6][2], root[6][5], True), (root[6][2], root[6][6], True), ) for node1, node2, exp_result in hash_tests: view1 = mmimport.basic_view(node1) view2 = mmimport.basic_view(node2) id1, chash1, ehash1 = view1.hash_this_node() id2, chash2, ehash2 = view2.hash_this_node() test_factory(ehash1 == ehash2, exp_result, "expected %s for %r == %r" % (exp_result, ehash1, ehash2)) test_factory(chash1 == chash2, False, "expected %s for %r == %r" % (False, chash1, chash2)) sibling_tests = ( (root[7][0][0], False), (root[7][0][1], False), (root[7][0][2], False), (root[7][0][3], True), ) for node, exp_result in sibling_tests: v = mmimport.sibling_view(node) test_factory(v.use_this_fact(), exp_result) mapname_tests = (
(root[2][1], root[2][2], False), (root[2][2], root[2][0], False), (root[6][0], root[6][1], True), (root[6][2], root[6][3], True), (root[6][2], root[6][4], True), (root[6][2], root[6][5], True), (root[6][2], root[6][6], True), ) for node1, node2, exp_result in hash_tests: view1 = mmimport.basic_view(node1) view2 = mmimport.basic_view(node2) id1, chash1, ehash1 = view1.hash_this_node() id2, chash2, ehash2 = view2.hash_this_node() test_factory(ehash1 == ehash2, exp_result, "expected %s for %r == %r" % (exp_result, ehash1, ehash2)) test_factory(chash1 == chash2, False, "expected %s for %r == %r" % (False, chash1, chash2)) sibling_tests = ( (root[7][0][0], False), (root[7][0][1], False), (root[7][0][2], False), (root[7][0][3], True), ) for node, exp_result in sibling_tests: v = mmimport.sibling_view(node) test_factory(v.use_this_fact(), exp_result)
f = get_nodes.mmnode_plus.parse_node_text states = ('ignore', 'ignore_all', 'ignore_children') tests = ( ('hello', ()), ('hello (i)', ('ignore',)), ('hello (ic)', ('ignore_children',)), ('hello (ia)', ('ignore_all',)), ('school principal interview after leaving (ic) (m: magnet)', ('ignore_children',)) ) for test in tests: result = f(test[0]) for state in states: test_factory(state in test[1], result.get(state) or False, "Unexpected %s for state %s on input %s" % (result.get(state), state, test[0])) root = get_nodes.mmnode_plus.factory('testmap.mm') test_factory('lie to me', root.ultimate_parent().text) tests = [