Greetings. I'm digging django pretty good. Many thanks.
I've run into a problem that I'm sure is my fault but I don't know why
yet. I've got a ModelForm and I'm trying to write unit tests for the
validation bits. My strategy here was to construct an instance of the
form and populate it with data and then call the appropriate
clean_<field>() method and make sure it does the right thing. Roughly
it looks like this:
TheFormClass<blah>
def clean_field(self):
field_val = self.cleaned_data['field']
# do sexy django validation tricks
and the test method looks like this:
def test_sexy_validation_is_dead_sexy(self):
model_object = ModelObject()
# Set some values on model_object
form = TheFormClass(instance=model_object)
form.clean_field()
Running the test causes a splash of barf that says:
AttributeError: 'TheFormClass' object has no attribute 'cleaned_data'
I've tried calling form.full_clean() with no better luck and
form.clean() which gives the same AttributeError. So to the question.
What am I doing wrong here? I've been living in Java land for a long
time so I'm suspecting I might be philosophically wrong about how to
test this stuff, especially since I can't (easily) find any mention of
this sort of thing on the web.
Any help much appreciated.
TIA,
---Rick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---