I have a form that a user submits that has a lot of processing on the back end. In that processing, I create a dictionary:
def function_that_returns_form_data(form, ...):
form_data = {'account' : form['account'], ...}
return form_data
My unit test testing the function which returns the dictionary looks something like:
self.form = PaymentForm(data=...)
returned_dict = function_that_returns_form_data(self.form, ...)
expected_dict = {'account' : self.form['account'], ...}
self.assertEqual(expected_dict, function_returning_form_data)
All the items in returned_dict
and expected_dict
match except for 'account', which causes an error:
AssertionError: Lists differ: ... First differing element 0: {'account': <django.forms.forms.BoundField object at 0x043E6F50>, ... {'account': <django.forms.forms.BoundField object at 0x043E64B0>, ...
I'm POSITIVE that these objects are the same, and I want to pass along the object instead of pulling out all of its fields individually. How can I get Django to test a bound field with a normal comparison (of the field's value) instead of comparing the location of the object in memory?
Aucun commentaire:
Enregistrer un commentaire