[Zope3-checkins] SVN: zope.testing/trunk/src/zope/testing/module.py No-longer have to pass the module name to tearDown. Also

Jim Fulton jim at zope.com
Thu Sep 29 05:21:32 EDT 2005


Log message for revision 38684:
  No-longer have to pass the module name to tearDown.  Also
  assign the module into it's parent module, so gettattr on the parent
  module works.
  

Changed:
  U   zope.testing/trunk/src/zope/testing/module.py

-=-
Modified: zope.testing/trunk/src/zope/testing/module.py
===================================================================
--- zope.testing/trunk/src/zope/testing/module.py	2005-09-29 09:12:49 UTC (rev 38683)
+++ zope.testing/trunk/src/zope/testing/module.py	2005-09-29 09:21:32 UTC (rev 38684)
@@ -30,7 +30,18 @@
 def setUp(test, name='README.txt'):
     dict = test.globs
     dict['__name__'] = name
-    sys.modules[name] = FakeModule(dict)
+    module = FakeModule(dict)
+    sys.modules[name] = module
+    if '.' in name:
+        name = name.split('.')
+        parent = sys.modules['.'.join(name[:-1])]
+        setattr(parent, name[-1], module)
 
-def tearDown(test, name='README.txt'):
+def tearDown(test, name=None):
+    if name is None:
+        name = test.globs['__name__']
     del sys.modules[name]
+    if '.' in name:
+        name = name.split('.')
+        parent = sys.modules['.'.join(name[:-1])]
+        delattr(parent, name[-1])



More information about the Zope3-Checkins mailing list