[pypy-svn] r50620 - in pypy/branch/clr-module-improvements/pypy/module/clr: . test
pdg at codespeak.net
pdg at codespeak.net
Tue Jan 15 12:07:55 CET 2008
Author: pdg
Date: Tue Jan 15 12:07:54 2008
New Revision: 50620
Modified:
pypy/branch/clr-module-improvements/pypy/module/clr/app_importer.py
pypy/branch/clr-module-improvements/pypy/module/clr/interp_clr.py
pypy/branch/clr-module-improvements/pypy/module/clr/test/test_importer.py
pypy/branch/clr-module-improvements/pypy/module/clr/test/test_interp_clr.py
Log:
(antocuni, pdg) Fixed lazy import tests
Modified: pypy/branch/clr-module-improvements/pypy/module/clr/app_importer.py
==============================================================================
--- pypy/branch/clr-module-improvements/pypy/module/clr/app_importer.py (original)
+++ pypy/branch/clr-module-improvements/pypy/module/clr/app_importer.py Tue Jan 15 12:07:54 2008
@@ -14,7 +14,7 @@
receive a second argument, which is None for a top-level module, or
package.__path__ for submodules or subpackages
- It should return a loader object if the module was found, or None if it wasn't.
+ It should return a loader object if the module was found, or None if it wasn\'t.
If find_module() raises an exception, the caller will abort the import.
When importer.find_module("spam.eggs.ham") is called, "spam.eggs" has already
been imported and added to sys.modules.
@@ -50,7 +50,7 @@
C The __name__ attribute must be set. If one uses
imp.new_module() then the attribute is set automatically.
- D If it's a package, the __path__ variable must be set. This must
+ D If it\'s a package, the __path__ variable must be set. This must
be a list, but may be empty if __path__ has no further
significance to the importer (more on this later).
Modified: pypy/branch/clr-module-improvements/pypy/module/clr/interp_clr.py
==============================================================================
--- pypy/branch/clr-module-improvements/pypy/module/clr/interp_clr.py (original)
+++ pypy/branch/clr-module-improvements/pypy/module/clr/interp_clr.py Tue Jan 15 12:07:54 2008
@@ -194,16 +194,21 @@
Return: List of Valid .NET namespaces
"""
- listOfNamespaces = []
+ namespaces = {}
currentDomain = System.AppDomain.get_CurrentDomain()
assems = currentDomain.GetAssemblies()
for loadedAssembly in assems:
typesInAssembly = loadedAssembly.GetTypes()
for type in typesInAssembly:
namespace = type.get_Namespace()
- if namespace != None and namespace not in listOfNamespaces:
- listOfNamespaces.append(namespace)
- w_listOfNamespaces = wrap_list_of_strings(space, listOfNamespaces)
+ if namespace != None:
+ chunks = namespace.split(".")
+ temp_name = chunks[0]
+ namespaces[temp_name] = None
+ for chunk in chunks[1:]:
+ temp_name += "."+chunk
+ namespaces[temp_name] = None
+ w_listOfNamespaces = wrap_list_of_strings(space, namespaces.keys())
return w_listOfNamespaces
def list_of_generic_classes(space):
Modified: pypy/branch/clr-module-improvements/pypy/module/clr/test/test_importer.py
==============================================================================
--- pypy/branch/clr-module-improvements/pypy/module/clr/test/test_importer.py (original)
+++ pypy/branch/clr-module-improvements/pypy/module/clr/test/test_importer.py Tue Jan 15 12:07:54 2008
@@ -5,6 +5,15 @@
space = gettestobjspace(usemodules=('clr', ))
cls.space = space
+ def test_list_of_valid_namespaces(self):
+ import clr
+ ns = clr.list_of_valid_namespaces()
+
+ assert 'System' in ns
+ assert 'System.Collections' in ns
+ assert 'System.Runtime' in ns
+ assert 'System.Runtime.InteropServices' in ns
+
def test_import_hook_simple(self):
import clr
import System.Math
@@ -41,4 +50,4 @@
def test_lazy_import(self):
import System
- System.Xml.Schema # does not raise attribute error
+ System.Runtime.InteropServices # does not raise attribute error
Modified: pypy/branch/clr-module-improvements/pypy/module/clr/test/test_interp_clr.py
==============================================================================
--- pypy/branch/clr-module-improvements/pypy/module/clr/test/test_interp_clr.py (original)
+++ pypy/branch/clr-module-improvements/pypy/module/clr/test/test_interp_clr.py Tue Jan 15 12:07:54 2008
@@ -7,3 +7,4 @@
assert split('System.Foo.Bar') == ('System.Foo', 'Bar')
assert split('System.Foo.A+B') == ('System.Foo', 'A+B')
assert split('System.') == ('System', '')
+
More information about the Pypy-commit
mailing list