[Zope-CVS] CVS: Products/FileCacheManager/tests -
testFileCacheManager.py:1.3
Jens Vagelpohl
jens at dataflake.org
Fri Aug 13 05:23:18 EDT 2004
Update of /cvs-repository/Products/FileCacheManager/tests
In directory cvs.zope.org:/tmp/cvs-serv933/tests
Modified Files:
testFileCacheManager.py
Log Message:
- add "if __name__ == '__main__'" clause to enable running the tests
using zopectl run
- rewrite tests so they work correctly with a filestream_iterator
instead of the previously used file_producer.
=== Products/FileCacheManager/tests/testFileCacheManager.py 1.2 => 1.3 ===
--- Products/FileCacheManager/tests/testFileCacheManager.py:1.2 Fri Aug 13 04:41:20 2004
+++ Products/FileCacheManager/tests/testFileCacheManager.py Fri Aug 13 05:23:17 2004
@@ -1,7 +1,8 @@
import os, unittest, warnings
import random
+from ZPublisher.Iterators import filestream_iterator
from Products.FileCacheManager.FileCacheManager import FileCache, \
- FileCacheManager, file_producer
+ FileCacheManager
FCM_ID = 'fcm1'
FCM_TITLE = 'Testing FileCacheManager'
@@ -57,13 +58,19 @@
for ob in self.all_files:
self.FC.ZCache_set(ob) # assume that works.
- # we should get back a file_producer.
- producer = self.FC.ZCache_get(ob)
- self.failUnless(isinstance(producer, file_producer))
- # getting all data from the file_producer ...
+
+ # we should get back a filestream_iterator.
+ file_iter = self.FC.ZCache_get(ob)
+ self.failUnless(isinstance(file_iter, filestream_iterator))
+
+ # getting all data from the filestream_iterator ...
all_data = []
- while not producer.done:
- all_data.append(producer.more())
+ while 1:
+ try:
+ all_data.append(file_iter.next())
+ except StopIteration:
+ break
+
all_data = ''.join(all_data)
# it should be the right data.
self.assertEqual(ob.data, all_data)
@@ -104,4 +111,8 @@
def run():
unittest.TextTestRunner().run(test_suite())
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
+
More information about the Zope-CVS
mailing list