From 1c440787510698aa71c39cfa8042899dcbecdc96 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Jul 2013 20:00:17 +0100 Subject: [PATCH] Improve testing of %pythonprepend and %pythonappend --- .../test-suite/python/python_append_runme.py | 7 +++++++ Examples/test-suite/python_append.i | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py index c8e6b2640..41cebad58 100644 --- a/Examples/test-suite/python/python_append_runme.py +++ b/Examples/test-suite/python/python_append_runme.py @@ -2,3 +2,10 @@ from python_append import * t=Test() t.func() t.static_func() + +if grabpath() != os.path.dirname(mypath): + raise RuntimeError + +if grabstaticpath() != os.path.basename(mypath): + raise RuntimeError + diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i index 2dc9cb970..82d1012ef 100644 --- a/Examples/test-suite/python_append.i +++ b/Examples/test-suite/python_append.i @@ -4,19 +4,34 @@ Testcase to test %pythonprepend and %pythonappend %module python_append +%pythoncode %{ + import os.path + mypath = os.path.dirname("/a/b/c/d.txt") + funcpath = None + staticfuncpath = None + def grabpath(): + return funcpath + def grabstaticpath(): + return staticfuncpath +%} + %pythonappend Test::func %{ - pass + funcpath = os.path.dirname(funcpath) %} %pythonprepend Test::func %{ - pass + global funcpath + funcpath = mypath %} %pythonappend Test::static_func %{ +staticfuncpath = os.path.basename(staticfuncpath) pass %} %pythonprepend Test::static_func { + global staticfuncpath + staticfuncpath = mypath pass }