def evaluate_as_nodeset(self, context): # Lazily generate the Python function for the expression. compiler = xpathcompiler(context) self.compile_as_nodeset(compiler) self.evaluate_as_nodeset = compiler.compile('evaluate_as_nodeset', docstring=unicode(self)) return self.evaluate_as_nodeset(context)
def new_tst_method(cls, expected, factory, args, node, principal_type=element): ctx = context(node, namespaces=NAMESPACES) compiler = xpathcompiler(ctx) # apply node-test using the default axis, 'child' nodes = iter(node) def test_method(self): node_test = factory(*args) node_filter = node_test.get_filter(compiler, principal_type) if node_filter: result = node_filter.select(ctx, nodes) else: result = nodes self.assertEquals(expected, list(result)) return test_method