diff options
Diffstat (limited to 'python/tests')
-rw-r--r-- | python/tests/Makefile.am | 2 | ||||
-rwxr-xr-x | python/tests/basic.py | 2 | ||||
-rwxr-xr-x | python/tests/extfunc.py | 21 | ||||
-rwxr-xr-x | python/tests/pyxsltproc.py | 3 |
4 files changed, 23 insertions, 5 deletions
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am index df032649..478e1087 100644 --- a/python/tests/Makefile.am +++ b/python/tests/Makefile.am @@ -26,6 +26,6 @@ clean: install-data-local: $(mkinstalldirs) $(DESTDIR)$(EXAMPLE_DIR) - -(for test in $(TESTSPY) $(XMLS); \ + -(for test in $(TESTSPY) $(XMLS) $(EXTRAS); \ do @INSTALL@ -m 0644 $$test $(DESTDIR)$(EXAMPLE_DIR) ; done) diff --git a/python/tests/basic.py b/python/tests/basic.py index 1c62cde4..9eea288d 100755 --- a/python/tests/basic.py +++ b/python/tests/basic.py @@ -11,7 +11,7 @@ style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseFile("test.xml") result = style.applyStylesheet(doc, None) style.saveResultToFilename("foo", result, 0) -style = None +style.freeStylesheet() doc.freeDoc() result.freeDoc() diff --git a/python/tests/extfunc.py b/python/tests/extfunc.py index 7e8b2845..c8f2fe24 100755 --- a/python/tests/extfunc.py +++ b/python/tests/extfunc.py @@ -6,7 +6,22 @@ import libxslt # Memory debug specific libxml2.debugMemory(1) -def f(str): +nodeName = None + +def f(ctx, str): + global nodeName + + # + # Small check to verify the context is correcly accessed + # + try: + pctxt = libxslt.xpathParserContext(_obj=ctx) + ctxt = pctxt.context() + tctxt = ctxt.transformContext() + nodeName = tctxt.insertNode().name + except: + pass + import string return string.upper(str) @@ -27,7 +42,7 @@ styledoc = libxml2.parseDoc(""" style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseDoc("<doc/>") result = style.applyStylesheet(doc, { "bar": "'success'" }) -style = None +style.freeStylesheet() doc.freeDoc() root = result.children @@ -37,6 +52,8 @@ if root.name != "article": if root.content != "SUCCESS": print "Unexpected root node content, extension function failed" sys.exit(1) +if nodeName != 'article': + print "The function callback failed to access its context" result.freeDoc() diff --git a/python/tests/pyxsltproc.py b/python/tests/pyxsltproc.py index fed201fd..fd21521e 100755 --- a/python/tests/pyxsltproc.py +++ b/python/tests/pyxsltproc.py @@ -283,7 +283,8 @@ def main(args = None): xsltProcess(doc, cur, args[i]) i = i + 1 - cur = None + if cur != None: + cur.freeStylesheet() params = None if __name__ == "__main__": |