def test_joined_string_regex(): schema = JoinedString.using(separator=u', ', separator_regex=re.compile('X*,X*')) el = schema(u'abc') assert el.value == u'abc' assert [child.value for child in el] == [u'abc'] el = schema(u'abcX,Xdef') assert el.value == u'abc, def' assert [child.value for child in el] == [u'abc', u'def']
def test_joined_string_regex(): schema = JoinedString.using(separator=u', ', separator_regex=re.compile('X*,X*')) el = schema(u'abc') assert el.value == u'abc' assert [child.value for child in el] == [u'abc'] el = schema(u'abcX,Xdef') assert el.value == u'abc, def' assert [child.value for child in el] == [u'abc', u'def']
def test_joined_non_string(): schema = JoinedString.using(member_schema=Integer) el = schema(u'1') assert el.value == u'1' assert [child.value for child in el] == [1] el = schema(u'1, 2, 3') assert el.value == u'1,2,3' assert [child.value for child in el] == [1, 2, 3] el = schema([1, 2, 3]) assert el.value == u'1,2,3' assert [child.value for child in el] == [1, 2, 3]
def test_joined_non_string(): schema = JoinedString.using(member_schema=Integer) el = schema(u'1') assert el.value == u'1' assert [child.value for child in el] == [1] el = schema(u'1, 2, 3') assert el.value == u'1,2,3' assert [child.value for child in el] == [1, 2, 3] el = schema([1, 2, 3]) assert el.value == u'1,2,3' assert [child.value for child in el] == [1, 2, 3]