[Zope3-checkins] SVN: Zope3/branches/3.3/src/zope/component/ Merge trunk rev 69342:

Gary Poster gary at zope.com
Thu Aug 3 22:43:39 EDT 2006


Log message for revision 69346:
  Merge trunk rev 69342:
    Test and fix for http://www.zope.org/Collectors/Zope3-dev/674
  
  

Changed:
  U   Zope3/branches/3.3/src/zope/component/globalregistry.py
  A   Zope3/branches/3.3/src/zope/component/standalonetests.py
  U   Zope3/branches/3.3/src/zope/component/tests.py

-=-
Modified: Zope3/branches/3.3/src/zope/component/globalregistry.py
===================================================================
--- Zope3/branches/3.3/src/zope/component/globalregistry.py	2006-08-04 02:35:12 UTC (rev 69345)
+++ Zope3/branches/3.3/src/zope/component/globalregistry.py	2006-08-04 02:43:39 UTC (rev 69346)
@@ -169,3 +169,12 @@
 
 def provideHandler(factory, adapts=None):
     base.registerHandler(factory, adapts, event=False)
+
+import zope.component._api # see http://www.zope.org/Collectors/Zope3-dev/674
+# Ideally, we will switch to an explicit adapter hook registration.  For now,
+# if you provide an adapter, we want to make sure that the adapter hook is
+# registered, and that registration depends on code in _api, which itself
+# depends on code in this module.  So, for now, we do another of these nasty
+# circular import workarounds.  See also standalonetests.py, as run by
+# tests.py in StandaloneTests, for a test that fails without this hack, and
+# succeeds with it.

Copied: Zope3/branches/3.3/src/zope/component/standalonetests.py (from rev 69345, Zope3/trunk/src/zope/component/standalonetests.py)

Modified: Zope3/branches/3.3/src/zope/component/tests.py
===================================================================
--- Zope3/branches/3.3/src/zope/component/tests.py	2006-08-04 02:35:12 UTC (rev 69345)
+++ Zope3/branches/3.3/src/zope/component/tests.py	2006-08-04 02:43:39 UTC (rev 69346)
@@ -925,8 +925,26 @@
 
     """
 
+class StandaloneTests(unittest.TestCase):
+    def testStandalone(self):
+        import subprocess
+        import sys
+        import os
+        import StringIO
+        import tempfile
+        executable = os.path.abspath(sys.executable)
+        program = os.path.join(os.path.dirname(__file__), 'standalonetests.py')
+        paths = ':'.join(sys.path)
+        command = "%(executable)s %(program)s %(paths)s" % {
+            'executable': executable, 'program': program, 'paths': paths}
+        t = tempfile.TemporaryFile()
+        res = subprocess.call([executable, program, paths], stdout=t, stderr=t)
+        t.seek(0)
+        lines = t.readlines()
+        t.close()
+        if lines[-1][-3:-1] != 'OK':
+            self.fail(''.join(lines))
 
-
 def tearDownRegistryTests(tests):
     import zope.event
     zope.event.subscribers.pop()
@@ -959,6 +977,7 @@
                              setUp=setUp, tearDown=tearDown),
         doctest.DocFileSuite('zcml.txt',
                              setUp=setUp, tearDown=tearDown),
+        unittest.makeSuite(StandaloneTests),
         ))
 
 if __name__ == "__main__":



More information about the Zope3-Checkins mailing list