@pytest.mark.parametrize('value', [[u'foo\\bar'], [u' DCTB  foo\\bar\n'], [u'fo\xf6\r\nb\xe4r'], [u'fo\xf6\\r\\nb\xe4r'], [u'fo\xf6\r\n\\r\\nb\xe4r', u'b\xe4r\r\n\\r\\nb\xe4z'], [u'nfo\xf6\nb\xe4r'], [u'nfo\xf6\\nb\xe4r'], [u'fo\xf6\n\\nb\xe4r', u'b\xe4r\n\\nb\xe4z']])
def test_form_multistringformfield(value):
 def test_form_factory(nplurals):
  class TestForm(Form, ):
   value = MultiStringFormField(nplurals=nplurals)
  return TestForm
 data = {('value_%d' % i): val for (i, val) in enumerate(value)}
 form_class = test_form_factory(nplurals=len(value))
 form = form_class(data=data)
 assert form.is_valid()
 assert (form.cleaned_data == {'value': value})

@ pytest . mark . parametrize ( 'value' , [ [ u'foo\\bar' ] , [ u' DCTB  foo\\bar\n' ] , [ u'fo\xf6\r\nb\xe4r' ] , [ u'fo\xf6\\r\\nb\xe4r' ] , [ u'fo\xf6\r\n\\r\\nb\xe4r' , u'b\xe4r\r\n\\r\\nb\xe4z' ] , [ u'nfo\xf6\nb\xe4r' ] , [ u'nfo\xf6\\nb\xe4r' ] , [ u'fo\xf6\n\\nb\xe4r' , u'b\xe4r\n\\nb\xe4z' ] ] ) def test_form_multistringformfield ( value ) : def test_form_factory ( nplurals ) : class TestForm ( Form , ) : value = MultiStringFormField ( nplurals = nplurals ) return TestForm data = { ( 'value_%d' % i ) : val for ( i , val ) in enumerate ( value ) } form_class = test_form_factory ( nplurals = len ( value ) ) form = form_class ( data = data ) assert form . is_valid ( ) assert ( form . cleaned_data == { 'value' : value } )
tests multistringformfields value compression in a form .