[Zope-Checkins] SVN: Zope/trunk/lib/python/ Collector #1798, issue 1: ZopeTestCase no longer tries to

Stefan H. Holek stefan at epy.co.at
Fri Jun 10 06:36:30 EDT 2005


Log message for revision 30729:
  Collector #1798, issue 1: ZopeTestCase no longer tries to
  install products that were installed by Zope during startup.
  

Changed:
  U   Zope/trunk/lib/python/OFS/Application.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeLite.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt

-=-
Modified: Zope/trunk/lib/python/OFS/Application.py
===================================================================
--- Zope/trunk/lib/python/OFS/Application.py	2005-06-10 10:05:01 UTC (rev 30728)
+++ Zope/trunk/lib/python/OFS/Application.py	2005-06-10 10:36:30 UTC (rev 30729)
@@ -38,9 +38,6 @@
 import ZDOM
 from FindSupport import FindSupport
 
-# Dictionary of installed products, mainly used by ZopeTestCase.
-_installedProducts = {}
-
 class Application(Globals.ApplicationDefaultPermissions,
                   ZDOM.Root, Folder.Folder,
                   App.ProductRegistry.ProductRegistry, FindSupport):
@@ -624,13 +621,7 @@
         # together and do a default initialization.
         if done.has_key(product_name):
             continue
-        # We need to separately track what has been installed now, and
-        # what has been installed at a whole. This is because install_products
-        # should always install everything, but only once every time it's 
-        # called. The _installedProducts dictionary is later used by 
-        # ZopeTestCase to not install products twice.
         done[product_name]=1
-        _installedProducts[product_name]=1
         install_product(app, product_dir, product_name, meta_types,
                         folder_permissions, raise_exc=debug_mode)
 

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeLite.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeLite.py	2005-06-10 10:05:01 UTC (rev 30728)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeLite.py	2005-06-10 10:36:30 UTC (rev 30729)
@@ -99,6 +99,8 @@
 import App.ProductContext
 _write('.')
 
+_patched = False
+
 def _apply_patches():
     # Avoid expensive product import
     def null_import_products(): pass
@@ -116,18 +118,22 @@
     def null_register_help(self,directory='',clear=1,title_re=None): pass
     App.ProductContext.ProductContext.registerHelp = null_register_help
 
+    # Note that we applied the monkey patches
+    global _patched
+    _patched = True
+
 # Do not patch a running Zope
 if not Zope2._began_startup:
     _apply_patches()
 
 # Allow test authors to install Zope products into the test environment. Note
 # that installProduct() must be called at module level -- never from tests.
-from OFS.Application import get_folder_permissions, get_products, \
-     install_product, _installedProducts
+from OFS.Application import get_folder_permissions, get_products, install_product
 from OFS.Folder import Folder
 import Products
 
 _theApp = Zope2.app()
+_installedProducts = {}
 
 def hasProduct(name):
     '''Checks if a product can be found along Products.__path__'''
@@ -137,7 +143,7 @@
     '''Installs a Zope product.'''
     start = time.time()
     meta_types = []
-    if not _installedProducts.has_key(name):
+    if _patched and not _installedProducts.has_key(name):
         for priority, product_name, index, product_dir in get_products():
             if product_name == name:
                 if not quiet: _print('Installing %s ... ' % product_name)

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt	2005-06-10 10:05:01 UTC (rev 30728)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt	2005-06-10 10:36:30 UTC (rev 30729)
@@ -1,6 +1,8 @@
 Unreleased
 - Functional.publish() would hang if it got a request_method argument other
   than GET or HEAD while omitting the stdin argument.
+- installProduct() now becomes a noop if ZopeTestCase did not apply its
+  patches.
 
 0.9.8 (Zope 2.8 edition)
 - Renamed 'doctest' package to 'zopedoctest' because of name-shadowing

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py	2005-06-10 10:05:01 UTC (rev 30728)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py	2005-06-10 10:36:30 UTC (rev 30729)
@@ -97,7 +97,8 @@
 
 def importObjectFromFile(container, filename, quiet=0):
     '''Imports an object from a (.zexp) file into the given container.'''
-    from ZopeLite import _print
+    from ZopeLite import _print, _patched
+    quiet = quiet or not _patched
     start = time.time()
     if not quiet: _print("Importing %s ... " % os.path.basename(filename))
     container._importObjectFromFile(filename, verify=0)

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt	2005-06-10 10:05:01 UTC (rev 30728)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt	2005-06-10 10:36:30 UTC (rev 30729)
@@ -114,7 +114,7 @@
   ... GET /test_folder_1_/script?a=2 HTTP/1.1
   ... """, handle_errors=False)
   HTTP/1.1 500 Internal Server Error
-  ...Content-Type: text/html...exceptions.TypeError...
+  ...Content-Type: text/html...TypeError...
 
 Test Unauthorized
 



More information about the Zope-Checkins mailing list