Unit testing django inline formsets Unit testing django inline formsets django django

Unit testing django inline formsets


Initial forms in an inline formset need to tie back to existing models in the DB. Your setup doesn't create the related ChosenTrait instance (which is the pk you should be using for merit-0-id). If you are testing creating all new models then 'merit-INITIAL_FORMS' should be 0.


An empty field isn't the same as one with an empty string.

If a field is empty, the browser doesn't include it in the query string at all. However, you've simulated a POST with that field containing an empty string, which confuses things. Remove that key altogether from the dict.