add new DelimitedList test case
import itertools
import mock
import sys
+import datetime
import pytest
from marshmallow import Schema, post_load, class_registry, validates_schema
@@ -880,6 +881,22 @@ def test_delimited_list_as_string(web_request, parser):
assert data["ids"] == "1,2,3"
+def test_delimited_list_as_string_v2(web_request, parser):
+ # b26793ee8021b6cfe525ac4f05570c3c68a4debd commit info
+ web_request.json = {"dates": "2018-11-01,2018-11-02"}
+ schema_cls = argmap2schema(
+ {"dates": fields.DelimitedList(fields.DateTime(format="%Y-%m-%d"), as_string=True)}
+ )
+ schema = schema_cls()
+
+ parsed = parser.parse(schema, web_request)
+ assert parsed["dates"] == [datetime.datetime(2018, 11, 1), datetime.datetime(2018, 11, 2)]
+
+ dumped = schema.dump(parsed)
+ data = dumped.data if MARSHMALLOW_VERSION_INFO[0] < 3 else dumped
+ assert data["dates"] == "2018-11-01,2018-11-02"
+
+
def test_delimited_list_custom_delimiter(web_request, parser):
web_request.json = {"ids": "1|2|3"}
schema_cls = argmap2schema(
