[Checkins] SVN: zc.resourcelibrary/trunk/src/zc/resourcelibrary/ added a doctest for the retry method, this is only used when a zodb conflict occurs, and this is very hard to reproduce in a test

Bernd Dorn bernd.dorn at fhv.at
Thu Sep 21 14:00:41 EDT 2006


Log message for revision 70295:
  added a doctest for the retry method, this is only used when a zodb conflict occurs, and this is very hard to reproduce in a test

Changed:
  U   zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
  A   zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests.py

-=-
Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py	2006-09-21 17:38:15 UTC (rev 70294)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py	2006-09-21 18:00:40 UTC (rev 70295)
@@ -37,10 +37,29 @@
 
     def retry(self):
         """
-        Returns a response object to be used in a retry attempt
+        Returns a response object to be used in a retry attempt.
+
+        >>> response = Response()
+        >>> response
+        <zc.resourcelibrary.publication.Response object at ...>
+        >>> response1 = response.retry()
+        
+        The returned object is not the same.
+        >>> response1 is response
+        False
+
+        If resource_libraries are defined they are assigned to the new
+        response.
+        >>> rl = ['a','b','c']
+        >>> response.resource_libraries = rl
+        >>> response.retry().resource_libraries is rl
+        True
+        >>> response.retry().retry().resource_libraries is rl
+        True
         """
         response = super(Response, self).retry()
-        response.resource_libraries = self.resource_libraries
+        if hasattr(self, 'resource_libraries'):
+            response.resource_libraries = self.resource_libraries
         return response
 
     def _implicitResult(self, body):

Added: zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests.py
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests.py	2006-09-21 17:38:15 UTC (rev 70294)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests.py	2006-09-21 18:00:40 UTC (rev 70295)
@@ -0,0 +1,15 @@
+import doctest
+import unittest
+from zope.testing.doctestunit import DocTestSuite
+def test_suite():
+    
+    return unittest.TestSuite(
+        (
+        DocTestSuite('zc.resourcelibrary.publication',
+                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+                     ),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+    


Property changes on: zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native



More information about the Checkins mailing list