Commit e2922b0c authored by Stefan Behnel's avatar Stefan Behnel

modernise pyximport tests

parent 36fda830
import pyximport; pyximport.install(reload_support=True)
from __future__ import absolute_import, print_function
from pyximport import pyximport; pyximport.install(reload_support=True)
import os, sys
import time, shutil
import tempfile
def make_tempdir():
tempdir = os.path.join(tempfile.gettempdir(), "pyrex_temp")
if os.path.exists(tempdir):
......@@ -11,14 +15,17 @@ def make_tempdir():
os.mkdir(tempdir)
return tempdir
def remove_tempdir(tempdir):
shutil.rmtree(tempdir, 0, on_remove_file_error)
def on_remove_file_error(func, path, excinfo):
print "Sorry! Could not remove a temp file:", path
print "Extra information."
print func, excinfo
print "You may want to delete this yourself when you get a chance."
print("Sorry! Could not remove a temp file:", path)
print("Extra information.")
print(func, excinfo)
print("You may want to delete this yourself when you get a chance.")
def test():
pyximport._test_files = []
......@@ -52,14 +59,14 @@ def make_ext(name, filename):
time.sleep(1) # sleep a second to get safer mtimes
open(os.path.join(tempdir, "abc.txt"), "w").write(" ")
print "Here goes the reolad"
print("Here goes the reolad")
reload(dummy)
assert len(pyximport._test_files) == 1, pyximport._test_files
reload(dummy)
assert len(pyximport._test_files) ==0, pyximport._test_files
assert len(pyximport._test_files) == 0, pyximport._test_files
remove_tempdir(tempdir)
if __name__=="__main__":
test()
# reload seems to work for Python 2.3 but not 2.2.
from __future__ import absolute_import, print_function
import time, os, sys
import test_pyximport
from . import test_pyximport
# debugging the 2.2 problem
if 1:
from distutils import sysconfig
try:
......@@ -10,7 +11,8 @@ if 1:
except AttributeError:
pass
import pyxbuild
print pyxbuild.distutils.sysconfig == sysconfig
print(pyxbuild.distutils.sysconfig == sysconfig)
def test():
tempdir = test_pyximport.make_tempdir()
......@@ -28,6 +30,6 @@ def test():
assert hello.x == 2, "Reload should work on Python 2.3 but not 2.2"
test_pyximport.remove_tempdir(tempdir)
if __name__=="__main__":
test()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment