Пример #1
0
class CommaDelimitedTextFieldTest(TestCase):
    def setUp(self):
        self.field = CommaDelimitedTextField()

    def test_list_to_field(self):
        self.assertEqual(
                self.field.get_db_prep_value(PrettyPrintList([u'first', u'second', u'3'])),
                u'first,second,3')
    def test_field_to_list(self):
        self.assertEqual(
                self.field.to_python(u'first,   second,3,    4'),
                PrettyPrintList([u'first', u'second', u'3', u'4']))
    def test_sane_inverse(self):
        """
        Tests whether converting a list to a string and then back gives
        the same list.
        """
        l = PrettyPrintList([u'first', u'second', u'3'])
        self.assertEqual(
                self.field.to_python(self.field.get_db_prep_value(l)),
                l)
Пример #2
0
 def setUp(self):
     self.field = CommaDelimitedTextField()