def test_clean(self): field = StringListFormField(required=False, skipinitialspace=False) self.assertEqual(field.clean('hello, goodbye'), ['hello', ' goodbye']) self.assertEqual(field.clean('hello,goodbye'), ['hello', 'goodbye']) self.assertEqual(field.clean('"hello", goodbye'), ['hello', ' goodbye']) self.assertEqual(field.clean('"hello"," oh no "'), ['hello', ' oh no ']) self.assertEqual(field.clean('"hello","one,two"'), ['hello', 'one,two'])
def test_quotechar(self): field = StringListFormField(required=False, quotechar='|') self.assertEqual(field.clean('hello, goodbye'), ['hello', 'goodbye']) self.assertEqual(field.clean('hello,goodbye'), ['hello', 'goodbye']) self.assertEqual(field.clean('hello, goodbye'), ['hello', 'goodbye']) self.assertEqual(field.clean('"hello", goodbye'), ['"hello"', 'goodbye']) self.assertEqual(field.clean('"hello","oh, no"'), ['"hello"', '"oh', 'no"']) self.assertEqual(field.clean('hello,|oh, no|'), ['hello', 'oh, no'])
def test_quotechar(self): field = StringListFormField(required=False, quotechar="|") self.assertEqual(field.clean("hello, goodbye"), ["hello", "goodbye"]) self.assertEqual(field.clean("hello,goodbye"), ["hello", "goodbye"]) self.assertEqual(field.clean("hello, goodbye"), ["hello", "goodbye"]) self.assertEqual(field.clean('"hello", goodbye'), ['"hello"', "goodbye"]) self.assertEqual(field.clean('"hello","oh, no"'), ['"hello"', '"oh', 'no"']) self.assertEqual(field.clean("hello,|oh, no|"), ["hello", "oh, no"])