Merge branch 'remove-dependency-on-2to3'

* remove-dependency-on-2to3:
  Remove need for Python 2to3
  Modify examples to be both Python 2 and 3 compatible
  Remove python3 specific runme3.py test files
  Convert python tests using 2to3
  Convert python test scripts to be Python 2 and 3 compatible
  Convert swigobject python test to be python 2 and 3 compatible
  Convert two tests to work with both Python 2 and 3
  Improve director_exception Python test
  Remove further print statements from Python tests
  Improve Python testing catching exceptions
  Improve contract Python testcase testing
  Remove print statements from Python tests
This commit is contained in:
William S Fulton 2020-08-15 19:03:38 +01:00
commit baec830f75
147 changed files with 1193 additions and 1427 deletions

View file

@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress)
===========================
2020-08-15: wsfulton
[Python] All Python examples and tests are written to be Python 2 and Python 3
compatible, removing the need for 2to3 to run the examples or test-suite.
2020-08-13: wsfulton
[C#] Add support for void *VOID_INT_PTR for member variables.

View file

@ -381,13 +381,7 @@ python_static_cpp: $(SRCDIR_SRCS)
# Running a Python example
# -----------------------------------------------------------------
ifeq (,$(PY3))
PYSCRIPT = $(RUNME).py
else
PYSCRIPT = $(RUNME)3.py
endif
PY2TO3 = @PY2TO3@ `@PY2TO3@ -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
PYSCRIPT = $(RUNME).py
python_run: $(PYSCRIPT)
ifneq (,$(PYCODESTYLE))
@ -400,10 +394,6 @@ $(RUNME).py: $(SRCDIR)$(RUNME).py
cp $< $@
endif
$(RUNME)3.py: $(SRCDIR)$(RUNME).py
cp $< $@
$(PY2TO3) -w $@ >/dev/null 2>&1
# -----------------------------------------------------------------
# Version display
# -----------------------------------------------------------------
@ -421,7 +411,6 @@ python_clean:
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@ *$(PYTHON_SO)
rm -f $(TARGET).py
if test -f $(SRCDIR)$(RUNME).py; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi
case "x$(SRCDIR)" in x|x./);; *) rm -f $(RUNME).py;; esac

View file

@ -11,7 +11,7 @@ class PyCallback(example.Callback):
example.Callback.__init__(self)
def run(self):
print "PyCallback.run()"
print("PyCallback.run()")
# Create an Caller instance
@ -20,8 +20,8 @@ caller = example.Caller()
# Add a simple C++ callback (caller owns the callback, so
# we disown it first by clearing the .thisown flag).
print "Adding and calling a normal C++ callback"
print "----------------------------------------"
print("Adding and calling a normal C++ callback")
print("----------------------------------------")
callback = example.Callback()
callback.thisown = 0
@ -29,9 +29,9 @@ caller.setCallback(callback)
caller.call()
caller.delCallback()
print
print "Adding and calling a Python callback"
print "------------------------------------"
print("")
print("Adding and calling a Python callback")
print("------------------------------------")
# Add a Python callback (caller owns the callback, so we
# disown it first by calling __disown__).
@ -40,9 +40,9 @@ caller.setCallback(PyCallback().__disown__())
caller.call()
caller.delCallback()
print
print "Adding and calling another Python callback"
print "------------------------------------------"
print("")
print("Adding and calling another Python callback")
print("------------------------------------------")
# Let's do the same but use the weak reference this time.
@ -53,5 +53,5 @@ caller.delCallback()
# All done.
print
print "python exit"
print("")
print("python exit")

View file

@ -7,15 +7,15 @@ import example
# ----- Object creation -----
print "Creating some objects:"
print("Creating some objects:")
c = example.Circle(10)
print " Created circle", c
print(" Created circle %s" % c)
s = example.Square(10)
print " Created square", s
print(" Created square %s" % s)
# ----- Access a static member -----
print "\nA total of", example.cvar.Shape_nshapes, "shapes were created"
print("\nA total of %d shapes were created" % example.cvar.Shape_nshapes)
# ----- Member data access -----
@ -27,25 +27,25 @@ c.y = 30
s.x = -10
s.y = 5
print "\nHere is their current position:"
print " Circle = (%f, %f)" % (c.x, c.y)
print " Square = (%f, %f)" % (s.x, s.y)
print("\nHere is their current position:")
print(" Circle = (%f, %f)" % (c.x, c.y))
print(" Square = (%f, %f)" % (s.x, s.y))
# ----- Call some methods -----
print "\nHere are some properties of the shapes:"
print("\nHere are some properties of the shapes:")
for o in [c, s]:
print " ", o
print " area = ", o.area()
print " perimeter = ", o.perimeter()
print(" %s" % o)
print(" area = %s" % o.area())
print(" perimeter = %s" % o.perimeter())
# prevent o from holding a reference to the last object looked at
o = None
print "\nGuess I'll clean up now"
print("\nGuess I'll clean up now")
# Note: this invokes the virtual destructor
del c
del s
print example.cvar.Shape_nshapes, "shapes remain"
print "Goodbye"
print("%d shapes remain" % example.cvar.Shape_nshapes)
print("Goodbye")

View file

@ -2,22 +2,24 @@
import example
print "ICONST =", example.ICONST, "(should be 42)"
print "FCONST =", example.FCONST, "(should be 2.1828)"
print "CCONST =", example.CCONST, "(should be 'x')"
print "CCONST2 =", example.CCONST2, "(this should be on a new line)"
print "SCONST =", example.SCONST, "(should be 'Hello World')"
print "SCONST2 =", example.SCONST2, "(should be '\"Hello World\"')"
print "EXPR =", example.EXPR, "(should be 48.5484)"
print "iconst =", example.iconst, "(should be 37)"
print "fconst =", example.fconst, "(should be 3.14)"
print("ICONST = %s (should be 42)" % example.ICONST)
print("FCONST = %s (should be 2.1828)" % example.FCONST)
print("CCONST = %s (should be 'x')" % example.CCONST)
print("CCONST2 = %s (this should be on a new line)" % example.CCONST2)
print("SCONST = %s (should be 'Hello World')" % example.SCONST)
print("SCONST2 = %s (should be '\"Hello World\"')" % example.SCONST2)
print("EXPR = %s (should be 48.5484)" % example.EXPR)
print("iconst = %s (should be 37)" % example.iconst)
print("fconst = %s (should be 3.14)" % example.fconst)
try:
print "EXTERN = ", example.EXTERN, "(Arg! This shouldn't print anything)"
x = example.EXTERN
print("%s (Arg! This shouldn't print anything)" % x)
except AttributeError:
print "EXTERN isn't defined (good)"
print("EXTERN isn't defined (good)")
try:
print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)"
x = example.FOO
print("%s (Arg! This shouldn't print anything)" % x)
except AttributeError:
print "FOO isn't defined (good)"
print("FOO isn't defined (good)")

View file

@ -7,15 +7,15 @@ import example
x = 42
y = 105
g = example.gcd(x, y)
print "The gcd of %d and %d is %d" % (x, y, g)
print("The gcd of %d and %d is %d" % (x, y, g))
# Manipulate the Foo global variable
# Output its current value
print "Foo = ", example.cvar.Foo
print("Foo = %s" % example.cvar.Foo)
# Change its value
example.cvar.Foo = 3.1415926
# See if the change took effect
print "Foo = ", example.cvar.Foo
print("Foo = %s" % example.cvar.Foo)

View file

@ -2,4 +2,4 @@
import example
print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')"
print("example.Foo.bar.__doc__ = %s (Should be 'No comment')" % repr(example.Foo.bar.__doc__))

View file

@ -5,24 +5,24 @@
import example
print "Creating some objects:"
print("Creating some objects:")
c = example.MakeCircle(10)
print " Created circle", c
print(" Created circle %s" % c)
s = example.MakeSquare(10)
print " Created square", s
print(" Created square %s" % s)
r = example.MakeRectangleInt(10, 20)
print " Created rectangle", r
print(" Created rectangle %s" % r)
print "\nHere are some properties of the shapes:"
print("\nHere are some properties of the shapes:")
for o in [c, s, r]:
print " ", o
print " area = ", o.area()
print " perimeter = ", o.perimeter()
print(" %s" % o)
print(" area = %s" % o.area())
print(" perimeter = %s" % o.perimeter())
print "\nRunning pydoc, this is the equivalent to executing: pydoc -w ./example.py"
print("\nRunning pydoc, this is the equivalent to executing: pydoc -w ./example.py")
import pydoc
pydoc.writedoc("example")
print "Open example.html in your browser to view the generated python docs"
print("Open example.html in your browser to view the generated python docs")

View file

@ -5,24 +5,24 @@ import example
# ----- Object creation -----
# Print out the value of some enums
print "*** color ***"
print " RED =", example.RED
print " BLUE =", example.BLUE
print " GREEN =", example.GREEN
print("*** color ***")
print(" RED = %s" % example.RED)
print(" BLUE = %s" % example.BLUE)
print(" GREEN = %s" % example.GREEN)
print "\n*** Foo::speed ***"
print " Foo_IMPULSE =", example.Foo.IMPULSE
print " Foo_WARP =", example.Foo.WARP
print " Foo_LUDICROUS =", example.Foo.LUDICROUS
print("\n*** Foo::speed ***")
print(" Foo_IMPULSE = %s" % example.Foo.IMPULSE)
print(" Foo_WARP = %s" % example.Foo.WARP)
print(" Foo_LUDICROUS = %s" % example.Foo.LUDICROUS)
print "\nTesting use of enums with functions\n"
print("\nTesting use of enums with functions\n")
example.enum_test(example.RED, example.Foo.IMPULSE)
example.enum_test(example.BLUE, example.Foo.WARP)
example.enum_test(example.GREEN, example.Foo.LUDICROUS)
example.enum_test(1234, 5678)
print "\nTesting use of enum with class method"
print("\nTesting use of enum with class method")
f = example.Foo()
f.enum_test(example.Foo.IMPULSE)

View file

@ -7,36 +7,36 @@ import example
t = example.Test()
try:
t.unknown()
except RuntimeError, e:
print "incomplete type", e.args[0]
except RuntimeError as e:
print("incomplete type %s" % e.args[0])
try:
t.simple()
except RuntimeError, e:
print e.args[0]
except RuntimeError as e:
print(e.args[0])
try:
t.message()
except RuntimeError, e:
print e.args[0]
except RuntimeError as e:
print(e.args[0])
if not example.is_python_builtin():
try:
t.hosed()
except example.Exc, e:
print e.code, e.msg
except example.Exc as e:
print("%s %s" % (e.code, e.msg))
else:
try:
t.hosed()
except BaseException, e:
except BaseException as e:
# Throwing builtin classes as exceptions not supported (-builtin
# option)
print e
print(e)
for i in range(1, 4):
try:
t.multi(i)
except RuntimeError, e:
print e.args[0]
except example.Exc, e:
print e.code, e.msg
except RuntimeError as e:
print(e.args[0])
except example.Exc as e:
print("%s %s" % (e.code, e.msg))

View file

@ -2,44 +2,44 @@
import example
if example.is_python_builtin():
print "Skipping example: -builtin option does not support %exceptionclass"
print("Skipping example: -builtin option does not support %exceptionclass")
exit(0)
q = example.intQueue(10)
print "Inserting items into intQueue"
print("Inserting items into intQueue")
print type(example.FullError)
print(type(example.FullError))
try:
for i in range(0, 100):
q.enqueue(i)
except example.FullError, e:
print "Maxsize is", e.maxsize
except example.FullError as e:
print("Maxsize is %s" % e.maxsize)
print "Removing items"
print("Removing items")
try:
while 1:
while True:
q.dequeue()
except example.EmptyError, e:
except example.EmptyError as e:
pass
q = example.doubleQueue(1000)
print "Inserting items into doubleQueue"
print("Inserting items into doubleQueue")
try:
for i in range(0, 10000):
q.enqueue(i * 1.5)
except example.FullError, e:
print "Maxsize is", e.maxsize
except example.FullError as e:
print("Maxsize is %s" % e.maxsize)
print "Removing items"
print("Removing items")
try:
while 1:
while True:
q.dequeue()
except example.EmptyError, e:
except example.EmptyError as e:
pass

View file

@ -21,9 +21,9 @@ class CEO(example.Manager):
# the director wrappers to call CEO.getPosition.
e = CEO("Alice")
print e.getName(), "is a", e.getPosition()
print "Just call her \"%s\"" % e.getTitle()
print "----------------------"
print("%s is a %s" % (e.getName(), e.getPosition()))
print("Just call her \"%s\"" % e.getTitle())
print("----------------------")
# Create a new EmployeeList instance. This class does not have a C++
@ -40,7 +40,7 @@ list = example.EmployeeList()
e = e.__disown__()
list.addEmployee(e)
print "----------------------"
print("----------------------")
# Now we access the first four items in list (three are C++ objects that
# EmployeeList's constructor adds, the last is our CEO). The virtual
@ -59,13 +59,13 @@ print "----------------------"
# passes down through the C++ director class to the Python implementation
# in CEO. All this routing takes place transparently.
print "(position, title) for items 0-3:"
print("(position, title) for items 0-3:")
print " %s, \"%s\"" % (list.get_item(0).getPosition(), list.get_item(0).getTitle())
print " %s, \"%s\"" % (list.get_item(1).getPosition(), list.get_item(1).getTitle())
print " %s, \"%s\"" % (list.get_item(2).getPosition(), list.get_item(2).getTitle())
print " %s, \"%s\"" % (list.get_item(3).getPosition(), list.get_item(3).getTitle())
print "----------------------"
print(" %s, \"%s\"" % (list.get_item(0).getPosition(), list.get_item(0).getTitle()))
print(" %s, \"%s\"" % (list.get_item(1).getPosition(), list.get_item(1).getTitle()))
print(" %s, \"%s\"" % (list.get_item(2).getPosition(), list.get_item(2).getTitle()))
print(" %s, \"%s\"" % (list.get_item(3).getPosition(), list.get_item(3).getTitle()))
print("----------------------")
# Time to delete the EmployeeList, which will delete all the Employee*
# items it contains. The last item is our CEO, which gets destroyed as its
@ -75,8 +75,8 @@ print "----------------------"
# usual to destroy the object.
del list
print "----------------------"
print("----------------------")
# All done.
print "python exit"
print("python exit")

View file

@ -7,14 +7,14 @@ b = 42
# Now call our C function with a bunch of callbacks
print "Trying some C callback functions"
print " a =", a
print " b =", b
print " ADD(a,b) =", example.do_op(a, b, example.ADD)
print " SUB(a,b) =", example.do_op(a, b, example.SUB)
print " MUL(a,b) =", example.do_op(a, b, example.MUL)
print("Trying some C callback functions")
print(" a = %s" % a)
print(" b = %s" % b)
print(" ADD(a,b) = %s" % example.do_op(a, b, example.ADD))
print(" SUB(a,b) = %s" % example.do_op(a, b, example.SUB))
print(" MUL(a,b) = %s" % example.do_op(a, b, example.MUL))
print "Here is what the C callback function objects look like in Python"
print " ADD =", example.ADD
print " SUB =", example.SUB
print " MUL =", example.MUL
print("Here is what the C callback function objects look like in Python")
print(" ADD = %s" % example.ADD)
print(" SUB = %s" % example.SUB)
print(" MUL = %s" % example.MUL)

View file

@ -7,18 +7,18 @@ b = 42
# Now call our C function with a bunch of callbacks
print "Trying some C callback functions"
print " a =", a
print " b =", b
print " ADD(a,b) =", example.do_op(a, b, example.ADD)
print " SUB(a,b) =", example.do_op(a, b, example.SUB)
print " MUL(a,b) =", example.do_op(a, b, example.MUL)
print("Trying some C callback functions")
print(" a = %s" % a)
print(" b = %s" % b)
print(" ADD(a,b) = %s" % example.do_op(a, b, example.ADD))
print(" SUB(a,b) = %s" % example.do_op(a, b, example.SUB))
print(" MUL(a,b) = %s" % example.do_op(a, b, example.MUL))
print "Here is what the C callback function objects look like in Python"
print " ADD =", example.ADD
print " SUB =", example.SUB
print " MUL =", example.MUL
print("Here is what the C callback function objects look like in Python")
print(" ADD = %s" % example.ADD)
print(" SUB = %s" % example.SUB)
print(" MUL = %s" % example.MUL)
print "Call the functions directly..."
print " add(a,b) =", example.add(a, b)
print " sub(a,b) =", example.sub(a, b)
print("Call the functions directly...")
print(" add(a,b) = %s" % example.add(a, b))
print(" sub(a,b) = %s" % example.sub(a, b))

View file

@ -12,5 +12,5 @@ for i in range(0, 100):
a(i) # Note: function call
b(math.sqrt(i)) # Note: function call
print a.result()
print b.result()
print(a.result())
print(b.result())

View file

@ -1,15 +1,22 @@
# file: runme.py
# Test various properties of classes defined in separate modules
import sys
print("Testing the %import directive")
print "Testing the %import directive"
import base
import foo
import bar
import spam
def write_flush(s):
# Python 2/3 compatible write and flush
sys.stdout.write(s)
sys.stdout.flush()
# Create some objects
print "Creating some objects"
print("Creating some objects")
a = base.Base()
b = foo.Foo()
@ -17,91 +24,74 @@ c = bar.Bar()
d = spam.Spam()
# Try calling some methods
print "Testing some methods"
print "",
print "Should see 'Base::A' ---> ",
print("Testing some methods")
write_flush(" Should see 'Base::A' ---> ")
a.A()
print "Should see 'Base::B' ---> ",
write_flush(" Should see 'Base::B' ---> ")
a.B()
print "Should see 'Foo::A' ---> ",
write_flush(" Should see 'Foo::A' ---> ")
b.A()
print "Should see 'Foo::B' ---> ",
write_flush(" Should see 'Foo::B' ---> ")
b.B()
print "Should see 'Bar::A' ---> ",
write_flush(" Should see 'Bar::A' ---> ")
c.A()
print "Should see 'Bar::B' ---> ",
write_flush(" Should see 'Bar::B' ---> ")
c.B()
print "Should see 'Spam::A' ---> ",
write_flush(" Should see 'Spam::A' ---> ")
d.A()
print "Should see 'Spam::B' ---> ",
write_flush(" Should see 'Spam::B' ---> ")
d.B()
# Try some casts
print "\nTesting some casts\n"
print "",
print("\nTesting some casts\n")
x = a.toBase()
print "Should see 'Base::A' ---> ",
write_flush(" Should see 'Base::A' ---> ")
x.A()
print "Should see 'Base::B' ---> ",
write_flush(" Should see 'Base::B' ---> ")
x.B()
x = b.toBase()
print "Should see 'Foo::A' ---> ",
write_flush(" Should see 'Foo::A' ---> ")
x.A()
print "Should see 'Base::B' ---> ",
write_flush(" Should see 'Base::B' ---> ")
x.B()
x = c.toBase()
print "Should see 'Bar::A' ---> ",
write_flush(" Should see 'Bar::A' ---> ")
x.A()
print "Should see 'Base::B' ---> ",
write_flush(" Should see 'Base::B' ---> ")
x.B()
x = d.toBase()
print "Should see 'Spam::A' ---> ",
write_flush(" Should see 'Spam::A' ---> ")
x.A()
print "Should see 'Base::B' ---> ",
write_flush(" Should see 'Base::B' ---> ")
x.B()
x = d.toBar()
print "Should see 'Bar::B' ---> ",
write_flush(" Should see 'Bar::B' ---> ")
x.B()
print "\nTesting some dynamic casts\n"
print("\nTesting some dynamic casts\n")
x = d.toBase()
print " Spam -> Base -> Foo : ",
y = foo.Foo_fromBase(x)
if y:
print "bad swig"
else:
print "good swig"
print(" Spam -> Base -> Foo : {} swig".format("bad" if y else "good"))
print " Spam -> Base -> Bar : ",
y = bar.Bar_fromBase(x)
if y:
print "good swig"
else:
print "bad swig"
print(" Spam -> Base -> Bar : {} swig".format("good" if y else "bad"))
print " Spam -> Base -> Spam : ",
y = spam.Spam_fromBase(x)
if y:
print "good swig"
else:
print "bad swig"
print(" Spam -> Base -> Spam : {} swig".format("good" if y else "bad"))
print " Foo -> Spam : ",
y = spam.Spam_fromBase(b)
if y:
print "bad swig"
else:
print "good swig"
print(" Foo -> Spam : {} swig".format("bad" if y else "good"))

View file

@ -6,26 +6,26 @@ def run_except_on_windows(commandline, env=None):
if os.name != "nt" and sys.platform != "cygwin":
# Strange failures on windows/cygin/mingw
subprocess.check_call(commandline, env=env, shell=True)
print(" Finished running: " + commandline)
print((" Finished running: " + commandline))
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py")
if sys.version_info < (2, 5):
print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'"
print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'")
sys.exit(0)
if sys.version_info < (3, 0):
import py2.pkg2
print " Finished importing py2.pkg2"
print(" Finished importing py2.pkg2")
commandline = sys.executable + " -m py2.pkg2.bar"
run_except_on_windows(commandline)
commandline = sys.executable + " -m py2.pkg2.foo"
run_except_on_windows(commandline)
else:
import py3.pkg2
print " Finished importing py3.pkg2"
print(" Finished importing py3.pkg2")
# commandline = sys.executable + " -m py3.pkg2.bar"
# run_except_on_windows(commandline)
# commandline = sys.executable + " -m py3.pkg2.foo"

View file

@ -6,24 +6,24 @@ def run_except_on_windows(commandline, env=None):
if os.name != "nt" and sys.platform != "cygwin":
# Strange failures on windows/cygin/mingw
subprocess.check_call(commandline, env=env, shell=True)
print(" Finished running: " + commandline)
print((" Finished running: " + commandline))
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py")
if sys.version_info < (2, 5):
print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'"
print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'")
sys.exit(0)
if sys.version_info < (3, 0):
import py2.pkg2
print " Finished importing py2.pkg2"
print(" Finished importing py2.pkg2")
commandline = sys.executable + " -m py2.pkg2.bar"
run_except_on_windows(commandline)
else:
import py3.pkg2
print " Finished importing py3.pkg2"
print(" Finished importing py3.pkg2")
# commandline = sys.executable + " -m py3.pkg2.bar"
# run_except_on_windows(commandline)

View file

@ -6,24 +6,24 @@ def run_except_on_windows(commandline, env=None):
if os.name != "nt" and sys.platform != "cygwin":
# Strange failures on windows/cygin/mingw
subprocess.check_call(commandline, env=env, shell=True)
print(" Finished running: " + commandline)
print((" Finished running: " + commandline))
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py")
if sys.version_info < (2, 5):
print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'"
print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'")
sys.exit(0)
if sys.version_info < (3, 0):
import py2.pkg2
print " Finished importing py2.pkg2"
print(" Finished importing py2.pkg2")
commandline = sys.executable + " -m py2.pkg2.bar"
run_except_on_windows(commandline)
else:
import py3.pkg2
print " Finished importing py3.pkg2"
print(" Finished importing py3.pkg2")
# commandline = sys.executable + " -m py3.pkg2.bar"
# run_except_on_windows(commandline)

View file

@ -3,10 +3,10 @@ import sys
# Test import of a SWIG generated module renamed as the package's __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - module renamed as __init__.py"
print("Testing " + testname + " - module renamed as __init__.py")
if sys.version_info >= (3, 0, 0) and sys.version_info < (3, 3, 0):
print " Not importing as Python version is >= 3.0 and < 3.3"
print(" Not importing as Python version is >= 3.0 and < 3.3")
# Package detection does not work in these versions.
# Can be fixed by using this in the interface file:
# %module(moduleimport="from . import $module") foo # without -builtin
@ -14,7 +14,7 @@ if sys.version_info >= (3, 0, 0) and sys.version_info < (3, 3, 0):
sys.exit(0)
import pkg1
print " Finished importing pkg1"
print(" Finished importing pkg1")
if pkg1.foofunction(123) != 1230:
raise RuntimeError("foofunction failed")
@ -23,4 +23,4 @@ fc = pkg1.FooClass()
if fc.foomethod(1) != 6:
raise RuntimeError("foomethod failed")
print " Finished testing pkg1"
print(" Finished testing pkg1")

Some files were not shown because too many files have changed in this diff Show more