SVN: zope.testing/trunk/src/zope/testing/testrunner/importcheck.py - Ignore doctest-caused indirect imports.

Christian Theune <[email protected]>
Newsgroups gmane.comp.web.zope.zope3.cvs
Message-ID <20090129112303.D2DC8941B1__23014.576585456$1233244072$gmane$org@cvs.zope.org>
Log message for revision 95408:
  - Ignore doctest-caused indirect imports.
  - Use the module's id for caching the wrappers.
  

Changed:
  U   zope.testing/trunk/src/zope/testing/testrunner/importcheck.py

-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner/importcheck.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/importcheck.py	2009-01-29 11:17:53 UTC (rev 95407)
+++ zope.testing/trunk/src/zope/testing/testrunner/importcheck.py	2009-01-29 11:23:03 UTC (rev 95408)
@@ -40,6 +40,10 @@
             if (import_mod, name, real_mod) in WHITELIST:
                 # No warning for things on the whitelist.
                 pass
+            elif real_mod in ['doctest', 'zope.testing.doctest']:
+                # doctest regularly sticks stuff somewhere else. We
+                # ignore those.
+                pass
             elif import_mod == 'sys' and name in ['stdin', 'stdout']:
                 # Those are redirected regularly.
                 pass
@@ -89,13 +93,14 @@
             fromlist=None):
         result = ihooks.ModuleImporter.import_module(
             self, name, globals=globals, locals=locals, fromlist=fromlist)
-        if result.__name__ not in wrapper_cache:
+        if id(result) not in wrapper_cache:
             checker = IndirectAttributeAccessChecker(result)
             if not hasattr(result, '__all__'):
+                # Support * imports
                 checker.__all__ = [x for x in dir(result) if not
                         x.startswith('_')]
-            wrapper_cache[result.__name__] = checker
-        return wrapper_cache[result.__name__]
+            wrapper_cache[id(result)] = checker
+        return wrapper_cache[id(result)]
 
     def import_it(self, partname, fqname, parent, force_load=0):
         result = ihooks.ModuleImporter.import_it(self, partname, fqname,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.