Commit 5ae156cf authored by Tino Wildenhain's avatar Tino Wildenhain

Fix FileUpload object to support iterator protocol - see collector entry #1837

parent 7e38f374
......@@ -1422,7 +1422,8 @@ class FileUpload:
if hasattr(file, '__methods__'): methods=file.__methods__
else: methods= ['close', 'fileno', 'flush', 'isatty',
'read', 'readline', 'readlines', 'seek',
'tell', 'truncate', 'write', 'writelines']
'tell', 'truncate', 'write', 'writelines',
'__iter__'] # see Collector 1837
d=self.__dict__
for m in methods:
......
......@@ -619,6 +619,17 @@ class RequestTests( unittest.TestCase ):
req.close()
self.assertEqual(start_count, sys.getrefcount(s)) # The test
def testFileIteator(self):
# checks fileupload object supports the iterator protocol
# collector entry 1837
import sys
from StringIO import StringIO
s = StringIO(TEST_FILE_DATA)
env = TEST_ENVIRON.copy()
from ZPublisher.HTTPRequest import HTTPRequest
req = HTTPRequest(s, env, None)
req.processInputs()
self.assertEqual(list(req.form.get('file')),['test\n'])
def test_suite():
suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment