Improve testing of %pythonprepend and %pythonappend

This commit is contained in:
William S Fulton 2013-07-02 20:00:17 +01:00
commit 1c44078751
2 changed files with 24 additions and 2 deletions

View file

@ -2,3 +2,10 @@ from python_append import *
t=Test() t=Test()
t.func() t.func()
t.static_func() t.static_func()
if grabpath() != os.path.dirname(mypath):
raise RuntimeError
if grabstaticpath() != os.path.basename(mypath):
raise RuntimeError

View file

@ -4,19 +4,34 @@ Testcase to test %pythonprepend and %pythonappend
%module python_append %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 %{ %pythonappend Test::func %{
pass funcpath = os.path.dirname(funcpath)
%} %}
%pythonprepend Test::func %{ %pythonprepend Test::func %{
pass global funcpath
funcpath = mypath
%} %}
%pythonappend Test::static_func %{ %pythonappend Test::static_func %{
staticfuncpath = os.path.basename(staticfuncpath)
pass pass
%} %}
%pythonprepend Test::static_func { %pythonprepend Test::static_func {
global staticfuncpath
staticfuncpath = mypath
pass pass
} }