[pypy-svn] r11707 - in pypy/dist/pypy/lib: . test2
arigo at codespeak.net
arigo at codespeak.net
Sun May 1 17:52:35 CEST 2005
Author: arigo
Date: Sun May 1 17:52:34 2005
New Revision: 11707
Added:
pypy/dist/pypy/lib/test2/test_imp_extra.py (contents, props changed)
Modified:
pypy/dist/pypy/lib/imp.py
pypy/dist/pypy/lib/test2/support.py
Log:
Added dummy lock functions to the imp module.
Fixed support.py and wrote a short test for the imp module.
Modified: pypy/dist/pypy/lib/imp.py
==============================================================================
--- pypy/dist/pypy/lib/imp.py (original)
+++ pypy/dist/pypy/lib/imp.py Sun May 1 17:52:34 2005
@@ -9,9 +9,14 @@
import sys, os
-PY_SOURCE = 1
-PKG_DIRECTORY = 5
-C_BUILTIN = 6
+PY_SOURCE = 1
+PY_COMPILED = 2
+C_EXTENSION = 3
+PY_RESOURCE = 4
+PKG_DIRECTORY = 5
+C_BUILTIN = 6
+PY_FROZEN = 7
+PY_CODERESOURCE = 8
def get_magic():
return '\x3b\xf2\x0d\x0a'
@@ -70,3 +75,12 @@
return module
raise ValueError, 'invalid description argument: %r' % (description,)
+
+
+# XXX needs to be implemented when we have threads
+def lock_held():
+ return False
+def acquire_lock():
+ pass
+def release_lock():
+ pass
Modified: pypy/dist/pypy/lib/test2/support.py
==============================================================================
--- pypy/dist/pypy/lib/test2/support.py (original)
+++ pypy/dist/pypy/lib/test2/support.py Sun May 1 17:52:34 2005
@@ -26,7 +26,8 @@
# interactions later
cleanup_path()
cpython_mod = __import__(modname)
- assert os.path.dirname(cpython_mod.__file__) != lib_dir
+ if hasattr(cpython_mod, '__file__'):
+ assert os.path.dirname(cpython_mod.__file__) != lib_dir
filename = os.path.join(lib_dir, modname + '.py')
mod = new.module(modname)
mod.__file__ = filename
Added: pypy/dist/pypy/lib/test2/test_imp_extra.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lib/test2/test_imp_extra.py Sun May 1 17:52:34 2005
@@ -0,0 +1,25 @@
+import support
+imp = support.libmodule('imp')
+
+import os
+
+
+def test_find_module():
+ file, pathname, description = imp.find_module('StringIO')
+ assert file is not None
+ file.close()
+ assert os.path.exists(pathname)
+ pathname = pathname.lower()
+ assert (pathname.endswith('.py') or pathname.endswith('.pyc')
+ or pathname.endswith('.pyo'))
+ assert description in imp.get_suffixes()
+
+
+def test_suffixes():
+ for suffix, mode, type in imp.get_suffixes():
+ if mode == imp.PY_SOURCE:
+ assert suffix == '.py'
+ assert type == 'r'
+ elif mode == imp.PY_COMPILED:
+ assert suffix in ('.pyc', '.pyo')
+ assert type == 'rb'
More information about the Pypy-commit
mailing list