Commit 70b5d264 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Restricted: allow csv.

parent 2d42a55c
......@@ -433,6 +433,23 @@ class TestRestrictedPythonSecurity(ERP5TypeTestCase):
expected=[("a", 1), ("b", 2)]
)
def test_csv(self):
self.createAndRunScript('''
import csv
import six
from io import BytesIO, StringIO
if six.PY2:
io_ = BytesIO()
else:
io_ = StringIO()
csv_writer = csv.writer(io_)
csv_writer.writerow([1, None, 'a'])
io_.seek(0)
return io_.getvalue()
''',
expected='1,,a\r\n',
)
def test_lax_name(self):
self.createAndRunScript('''
def _function():
......
......@@ -345,6 +345,12 @@ if six.PY2:
allow_type(cStringIO.OutputType)
ModuleSecurityInfo('cgi').declarePublic('escape', 'parse_header')
import csv
allow_module('csv')
temp_io = io.StringIO()
allow_type(type(csv.reader(temp_io)))
allow_type(type(csv.writer(temp_io)))
del temp_io
allow_module('datetime')
import datetime
ContainerAssertions[datetime.datetime] = 1
......
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