Пример #1
0
 def test_to_python(self):
     tests = [
         # test data, expected
         (None, []),
         ([], []),
         ([1, 2, 3], [1, 2, 3]),
         (u'[1, 2, 3]', [1, 2, 3]),
         (u"[u'a', u'b', u'c']", [u'a', u'b', u'c'])
     ]
     field = ListField()
     for testcase, expected in tests:
         assert field.to_python(testcase) == expected
Пример #2
0
 def test_to_python(self):
     tests = [
         # test data, expected
         (None, []),
         ([], []),
         ([1, 2, 3], [1, 2, 3]),
         (u'[1, 2, 3]', [1, 2, 3]),
         (u"[u'a', u'b', u'c']", [u'a', u'b', u'c'])
     ]
     field = ListField()
     for testcase, expected in tests:
         assert field.to_python(testcase) == expected
Пример #3
0
 def test_to_python_raises_validationerror_on_syntaxerror(self):
     field = ListField()
     with pytest.raises(ValidationError):
         field.to_python('abc')
Пример #4
0
 def test_to_python_non_list_raises_validationerror_on_assert(self):
     field = ListField()
     with pytest.raises(ValidationError):
         field.to_python(42)