[Checkins] SVN: z3c.blobfile/trunk/ - Made tests compatible with ZODB 3.9.

Michael Howitz mh at gocept.com
Fri Apr 3 15:23:43 EDT 2009


Log message for revision 98849:
  - Made tests compatible with ZODB 3.9.
  - Removed version pinning in buildout as it is no longer necessary.
  - Added coverage analysis tools to buildout.cfg
  

Changed:
  U   z3c.blobfile/trunk/CHANGES.txt
  U   z3c.blobfile/trunk/buildout.cfg
  U   z3c.blobfile/trunk/src/z3c/blobfile/file.py
  U   z3c.blobfile/trunk/src/z3c/blobfile/testing.py

-=-
Modified: z3c.blobfile/trunk/CHANGES.txt
===================================================================
--- z3c.blobfile/trunk/CHANGES.txt	2009-04-03 19:22:16 UTC (rev 98848)
+++ z3c.blobfile/trunk/CHANGES.txt	2009-04-03 19:23:43 UTC (rev 98849)
@@ -5,14 +5,15 @@
 0.1.5 (unreleased)
 ------------------
 
-- ...
+- Made tests compatible with ZODB 3.9.
 
+
 0.1.4 (2009-03-03)
 ------------------
 
 - Add copy hook for zope.copy to fix blob file/image copying.
 - Change package's mailing list address to zope-dev at zope.org
-  instead of retired zope3-dev. 
+  instead of retired zope3-dev.
 
 0.1.3 (2008-10-20)
 ------------------

Modified: z3c.blobfile/trunk/buildout.cfg
===================================================================
--- z3c.blobfile/trunk/buildout.cfg	2009-04-03 19:22:16 UTC (rev 98848)
+++ z3c.blobfile/trunk/buildout.cfg	2009-04-03 19:23:43 UTC (rev 98849)
@@ -1,15 +1,21 @@
 [buildout]
 develop = .
-parts = test
-versions = versions
+parts = test coverage-test coverage-report
 
-# with zodb 3.9, DemoStorage currently fails with _tid attribute, so
-# nail ZODB version to 3.8.1 for tests.
-[versions]
-ZODB3 = 3.8.1
-
 [test]
 recipe = zc.recipe.testrunner
 eggs = z3c.blobfile [test]
 zcml = z3c.blobfile-overrides
 defaults = ['--tests-pattern', '^f?tests$', '-v']
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3c.blobfile [test]
+zcml = z3c.blobfile-overrides
+defaults = ['--tests-pattern', '^f?tests$', '-v', '--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')

Modified: z3c.blobfile/trunk/src/z3c/blobfile/file.py
===================================================================
--- z3c.blobfile/trunk/src/z3c/blobfile/file.py	2009-04-03 19:22:16 UTC (rev 98848)
+++ z3c.blobfile/trunk/src/z3c/blobfile/file.py	2009-04-03 19:23:43 UTC (rev 98849)
@@ -31,7 +31,7 @@
 class File(Persistent):
     """A persistent content component storing binary file data."""
 
-    implements(zope.app.publication.interfaces.IFileContent, 
+    implements(zope.app.publication.interfaces.IFileContent,
                interfaces.IBlobFile)
 
     def __init__(self, data='', contentType=''):
@@ -56,7 +56,7 @@
         # Search for a storable that is able to store the data
         dottedName = ".".join((data.__class__.__module__,
                                data.__class__.__name__))
-        storable = zope.component.getUtility(interfaces.IStorage, 
+        storable = zope.component.getUtility(interfaces.IStorage,
                                              name=dottedName)
         storable.store(data, self._blob)
 
@@ -65,10 +65,10 @@
         data = fp.read()
         fp.close()
         return data
-        
-    _data = property(_getData, _setData)   
-    data = property(_getData, _setData)    
 
+    _data = property(_getData, _setData)
+    data = property(_getData, _setData)
+
     @property
     def size(self):
         if 'size' in self.__dict__:
@@ -85,7 +85,7 @@
 
 class FileReadFile(object):
     """Adapter for file-system style read access."""
-    
+
     def __init__(self, context):
         self.context = context
 
@@ -98,7 +98,7 @@
 
 class FileWriteFile(object):
     """Adapter for file-system style write access."""
-    
+
     def __init__(self, context):
         self.context = context
 
@@ -107,9 +107,9 @@
 
 class FileReplacedEvent(zope.component.interfaces.ObjectEvent):
     """Notifies about the replacement of a zope.app.file with a z3c.blobfile."""
-    
+
     def __init__(self, object, blobfile):
         super(FileReplacedEvent, self).__init__(object)
         self.blobfile = blobfile
 
-    
\ No newline at end of file
+

Modified: z3c.blobfile/trunk/src/z3c/blobfile/testing.py
===================================================================
--- z3c.blobfile/trunk/src/z3c/blobfile/testing.py	2009-04-03 19:22:16 UTC (rev 98848)
+++ z3c.blobfile/trunk/src/z3c/blobfile/testing.py	2009-04-03 19:23:43 UTC (rev 98849)
@@ -25,6 +25,7 @@
 from ZODB.DB import DB
 from ZODB.DemoStorage import DemoStorage
 from ZODB.blob import BlobStorage
+import ZODB.interfaces
 
 import zope.interface
 from zope.testing import doctest
@@ -60,10 +61,11 @@
 
     data = 'My data'
     contentType = 'text/plain'
-    
+
 class FunctionalBlobTestSetup(zope.app.testing.functional.FunctionalTestSetup):
 
     temp_dir_name = None
+    direct_blob_support = False
 
     def setUp(self):
         """Prepares for a functional test case."""
@@ -71,10 +73,14 @@
         transaction.abort()
         self.db.close()
         storage = DemoStorage("Demo Storage", self.base_storage)
-        # make a dir
-        temp_dir_name = self.temp_dir_name = tempfile.mkdtemp()
-        # wrap storage with BlobStorage
-        storage = BlobStorage(temp_dir_name, storage)
+        if ZODB.interfaces.IBlobStorage.providedBy(storage):
+            # at least ZODB 3.9
+            self.direct_blob_support = True
+        else:
+            # make a dir
+            temp_dir_name = self.temp_dir_name = tempfile.mkdtemp()
+            # wrap storage with BlobStorage
+            storage = BlobStorage(temp_dir_name, storage)
         self.db = self.app.db = DB(storage)
         self.connection = None
 
@@ -85,25 +91,25 @@
             self.connection.close()
             self.connection = None
         self.db.close()
-        # del dir named '__blob_test__%s' % self.name
-        if self.temp_dir_name is not None:
+        if not self.direct_blob_support and self.temp_dir_name is not None:
+            # del dir named '__blob_test__%s' % self.name
             shutil.rmtree(self.temp_dir_name, True)
             self.temp_dir_name = None
         setSite(None)
-        
+
     def closeDB(self):
         if self.connection:
             self.connection.close()
             self.connection = None
         self.db.close()
-        
+
     def reopenDB(self):
         storage = BlobStorage(temp_dir_name, storage)
         self.db = self.app.db = DB(storage)
         self.connection = None
-        
 
 
+
 class ZCMLLayer(zope.app.testing.functional.ZCMLLayer):
 
     def setUp(self):
@@ -143,7 +149,7 @@
     suite = doctest.DocFileSuite(*paths, **kw)
     suite.layer = zope.app.testing.functional.Functional
     return suite
-    
+
 BlobFileLayer = ZCMLLayer(
     os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
     __name__, 'BlobFileLayer', allow_teardown=True)



More information about the Checkins mailing list