def test_compile(self): parser = Parser() nodes = [ Node(Node.STR, value='asd '), Node(Node.SLICE, stop=3), Node(Node.SLICE, start=1, stop=2), ] mask_func = parser.compile(nodes) self.assertIsInstance(mask_func, LambdaType) s = ''.join(map(str, range(10))) self.assertEqual(u'asd 31', mask_func(s))