You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_nullcharfield.py 905B

12345678910111213141516171819202122232425
  1. from django.core.exceptions import ImproperlyConfigured
  2. from django.test import TestCase
  3. from oscar.models.fields import NullCharField
  4. class NullCharFieldTest(TestCase):
  5. def test_from_db_value_converts_null_to_string(self):
  6. field = NullCharField()
  7. self.assertEqual('', field.from_db_value(None, expression=None, connection=None, context=None))
  8. def test_get_prep_value_converts_empty_string_to_null(self):
  9. field = NullCharField()
  10. self.assertEqual(None, field.get_prep_value(''))
  11. def test_raises_exception_for_invalid_null_blank_combo(self):
  12. with self.assertRaises(ImproperlyConfigured):
  13. NullCharField(null=True, blank=False)
  14. with self.assertRaises(ImproperlyConfigured):
  15. NullCharField(null=False, blank=True)
  16. with self.assertRaises(ImproperlyConfigured):
  17. NullCharField(null=False, blank=False)