dimanche 5 juin 2016

Django forms which needs the request , makes testing harder?

I have many django forms in which I pass the request as kwarg.
I've just started dive into testing, and it seems that testing forms which require the request as argument makes the testing harder. As I have to somehow create a request and I cant test my forms without it.

So is it best to avoid passing the request to the form at all? Or another workaround? The reason I do that on first place is that sometimes I need request.user, or request.session and do some cleaning/setting based on that info in the form.

Aucun commentaire:

Enregistrer un commentaire