ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> zope-checkins
zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.10/ backport support for testing against storages other than `DemoStorage` (r80357:80358) from Zope 2.11
by Andreas Zeidler other posts by this author
Oct 31 2009 4:28AM messages near this date
[Zope-Checkins] SVN: Zope/branches/2.12/ 2.12.1 | [Zope-Checkins] SVN: Zope/trunk/src/App/class_init.py Merged c105405 from 2.12 branch
Log message for revision 105407:
  backport support for testing against storages other than `DemoStorage` (r80357:80358) from
 Zope 2.11
  

Changed:
  U   Zope/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/lib/python/Testing/custom_zodb.py

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10/doc/CHANGES.txt	2009-10-31 11:04:38 UTC (rev 105406)
+++ Zope/branches/2.10/doc/CHANGES.txt	2009-10-31 11:27:55 UTC (rev 105407)
@@ -6,6 +6,16 @@
 
   Zope 2.10.10 (Unreleased)
 
+    Features added
+
+      - Testing/custom_zodb.py: added support use a different storage other
+        than DemoStorage. A dedicated FileStorage can be mount by setting the
+        $TEST_FILESTORAGE environment variable to a custom Data.fs file.  A 
+        ZEO server can be configured using the $TEST_ZEO_HOST and 
+        $TEST_ZEO_PORT environment variables. This new functionality allows us
+        to use the standard Zope testrunner for writing and running tests
+        against existing Zope installations.
+
     Bugs fixed
 
       - LP #360761 (backported from Acquisition trunk): fix iteration proxy

Modified: Zope/branches/2.10/lib/python/Testing/custom_zodb.py
===================================================================
--- Zope/branches/2.10/lib/python/Testing/custom_zodb.py	2009-10-31 11:04:38 UTC (rev 105406
)
+++ Zope/branches/2.10/lib/python/Testing/custom_zodb.py	2009-10-31 11:27:55 UTC (rev 105407
)
@@ -1,4 +1,36 @@
+
+import os
+import logging
 import ZODB
-from ZODB.DemoStorage import DemoStorage
 
-Storage = DemoStorage(quota=(1<<20))
+LOG = logging.getLogger('Testing')
+
+def getStorage():
+    """ Return a storage instance for running ZopeTestCase based 
+        tests. By default a DemoStorage is used. Setting
+        $TEST_ZEO_HOST/TEST_ZEO_PORT environment variables allows you
+        to use a ZEO server instead. A file storage can be configured
+        by settting the $TEST_FILESTORAGE environment variable.
+    """
+
+    get = os.environ.get
+
+    if os.environ.has_key('TEST_ZEO_HOST') and os.environ.has_key('TEST_ZEO_PORT'):
+        from ZEO.ClientStorage import ClientStorage
+        zeo_host = get('TEST_ZEO_HOST')
+        zeo_port = int(get('TEST_ZEO_PORT'))
+        LOG.info('Using ZEO server (%s:%d)' % (zeo_host, zeo_port))
+        return ClientStorage((zeo_host, zeo_port))
+
+    elif os.environ.has_key('TEST_FILESTORAGE'):
+        import ZODB.FileStorage
+        datafs = get('TEST_FILESTORAGE')
+        LOG.info('Using Filestorage at (%s)' % datafs)
+        return ZODB.FileStorage.FileStorage(datafs)
+
+    else:
+        from ZODB.DemoStorage import DemoStorage
+        LOG.info('Using DemoStorage')
+        return DemoStorage(quota=(1<<20))
+
+Storage = getStorage()

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@[...].org
https://mail.zope.org/mailman/listinfo/zope-checkins

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved