Well, looking at Ticket 9172 (http://code.djangoproject.com/ticket/
9172), we're supposed to be turning off the CSRF middleware during
tests.

I believe we can do that by writing another settings file, disabling
the Csrf Middleware and using that settings file to run our tests, as
per this thread.

However, I'm running into the problem that I have no clue if manage.py
ever read my settings file correctly. I'm assuming it didn't because I
still get the Cross Site Request Forgery error. I can import my
test_settings fine in the shell, so it's not the file that is
incorrect.

I'll dig into this more tonight.

Cheers,
Justin


On Feb 16, 4:12 pm, felix <crucialfe...@gmail.com> wrote:
> ah ha.
>
> yes, I've wasted several hours over this issue.  it took me a while to
> figure out that it was the CSRF middleware that was breaking the tests.
> both auth tests and actually every single one that tests the posting of
> forms.
>
> I didn't see it mention of this issue in either the CSRF docs or the unit
> test docs, but those are both places that we would first look to diagnose.
> a docs request ticket should be filed.  I couldn't find one existing.
>
> I thought it was something to do with self.client.login failing (because I
> would get 403)
>
> I couldn't figure this out: is there a way to tell that we are running as a
> test ?
>
>      felix :    crucial-systems.com
>
> On Mon, Feb 16, 2009 at 9:33 PM, stryderjzw <stryder...@gmail.com> wrote:
>
> > > from settings import *
>
> > > #CSRFMiddleware breaks authtests
> > > MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
> > > MIDDLEWARE_CLASSES.remove
> > > ('django.contrib.csrf.middleware.CsrfMiddleware')
>
> > > # Turn this off to allowteststhat look at http status to pass
> > > PREPEND_WWW = False
>
> sorry, I don't get this.  what fails ?  response.status_code == 200 ?
>
>
>
> > > I then run the test suite using this command:
> > > python manage.py test --settings=mysite.settings-test.py
>
> > > Best,
> > > Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to