Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: third_party/cython/src/pyximport/test/test_pyximport.py

Issue 385073004: Adding cython v0.20.2 in third-party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reference cython dev list thread. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/cython/src/pyximport/pyximport.py ('k') | third_party/cython/src/pyximport/test/test_reload.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/cython/src/pyximport/test/test_pyximport.py
diff --git a/third_party/cython/src/pyximport/test/test_pyximport.py b/third_party/cython/src/pyximport/test/test_pyximport.py
new file mode 100644
index 0000000000000000000000000000000000000000..e45d5ff7f434c90a4ef496cc2250305a633b07b4
--- /dev/null
+++ b/third_party/cython/src/pyximport/test/test_pyximport.py
@@ -0,0 +1,65 @@
+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):
+ remove_tempdir(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."
+
+def test():
+ pyximport._test_files = []
+ tempdir = make_tempdir()
+ sys.path.append(tempdir)
+ filename = os.path.join(tempdir, "dummy.pyx")
+ open(filename, "w").write("print 'Hello world from the Pyrex install hook'")
+ import dummy
+ reload(dummy)
+
+ depend_filename = os.path.join(tempdir, "dummy.pyxdep")
+ depend_file = open(depend_filename, "w")
+ depend_file.write("*.txt\nfoo.bar")
+ depend_file.close()
+
+ build_filename = os.path.join(tempdir, "dummy.pyxbld")
+ build_file = open(build_filename, "w")
+ build_file.write("""
+from distutils.extension import Extension
+def make_ext(name, filename):
+ return Extension(name=name, sources=[filename])
+""")
+ build_file.close()
+
+ open(os.path.join(tempdir, "foo.bar"), "w").write(" ")
+ open(os.path.join(tempdir, "1.txt"), "w").write(" ")
+ open(os.path.join(tempdir, "abc.txt"), "w").write(" ")
+ reload(dummy)
+ assert len(pyximport._test_files)==1, pyximport._test_files
+ reload(dummy)
+
+ time.sleep(1) # sleep a second to get safer mtimes
+ open(os.path.join(tempdir, "abc.txt"), "w").write(" ")
+ 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
+ remove_tempdir(tempdir)
+
+if __name__=="__main__":
+ test()
+
« no previous file with comments | « third_party/cython/src/pyximport/pyximport.py ('k') | third_party/cython/src/pyximport/test/test_reload.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698