'Test matching on nodes based on NLTK tree position.'

def test_node_tree_position(self):

    tree = ParentedTree.fromstring(u'(S    (NP-SBJ    x)    (NP    x)    (NNP    x)    (VP    x))')
    leaf_positions = set([tree.leaf_treeposition(x) for x in range(len(tree.leaves()))])
    tree_positions = [x for x in tree.treepositions() if (x not in leaf_positions)]
    for position in tree_positions:
        node_id = u'N{0}'.format(position)
        tgrep_positions = list(tgrep.tgrep_positions(node_id, [tree]))
        self.assertEqual(len(tgrep_positions[0]), 1)
        self.assertEqual(tgrep_positions[0][0], position)
