made BaseField.to_python() raise NotImplementedError (already documented) and adapted unittest

This commit is contained in:
Pablo Hoffman 2009-07-13 22:19:25 -03:00
parent a8aae41a13
commit ae82f8c70d
2 changed files with 2 additions and 7 deletions

View File

@ -9,14 +9,9 @@ class BaseField(object):
self._default = self.to_python(default) if default is not None else None
def to_python(self, value):
"""
Converts the input value into the expected Python data type.
Subclasses should override this.
"""
return value
raise NotImplementedError()
def get_default(self):
"""Returns the default value for the field."""
return self._default

View File

@ -125,7 +125,7 @@ class NewItemFieldsTest(unittest.TestCase):
f = fields.BaseField()
assert f.get_default() is None
assert f.to_python(1) == 1
self.assertRaises(NotImplementedError, f.to_python, 1)
def test_boolean_field(self):
class TestItem(Item):