Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-05 Thread Paulo Almeida
Mystery solved. The fixtures were not being imported after all. My list_experiments view imports files from a certain folder, and that was the experiment data being listed. Then the database was rolled back before the view_experiment test started, and naturally the experiment with id 1 was not the

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-05 Thread Paulo Almeida
Hi, Thanks for the suggestion. I will do that now, but in the mean time I realized the 404 is probably happening because of the get_object_or_404 in the view, which means the experiment really isn't there, or at least not with id 1. I confirmed that by replacing get_object_or_404 with: exp = Expe

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 10:45 +0100, Paulo Almeida wrote: > Ok, so with APPEND_SLASH = False , I get a 404 (so no > response['location']) , but the response.context still has all the > variables like MEDIA_URL, LANGUAGES, LANGUAGE_BIDI, and not the ones > it should have. It still has also: > > {'r

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-05 Thread Paulo Almeida
Ok, so with APPEND_SLASH = False , I get a 404 (so no response['location']) , but the response.context still has all the variables like MEDIA_URL, LANGUAGES, LANGUAGE_BIDI, and not the ones it should have. It still has also: {'request_path': u'/myflow/experiment/1'} I also tested another view, wi

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Paulo Almeida
Hi, The myflow part comes from the parent urls.py, which includes myflow/urls.py when matching ^myflow (sorry, didn't think of that). I did try to comment out the CommonMiddleware line, in settings.py, and the error persisted, but maybe I should try adding APPEND_SLASH = False. I will then look at

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Karen Tracey
On Tue, Aug 4, 2009 at 1:33 PM, Paulo Almeida wrote: > Hi Karen, > > You're right, I had some unnecessary lines that I used only for unittest. I > commented them out now. Printing response['location'] gives me this: > > http://testserver/myflow/experiment/1/ > > You're also right that there is no

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Paulo Almeida
Hi Karen, You're right, I had some unnecessary lines that I used only for unittest. I commented them out now. Printing response['location'] gives me this: http://testserver/myflow/experiment/1/ You're also right that there is no Redirect in my view, so I don't know where that is coming from. I g

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Karen Tracey
On Tue, Aug 4, 2009 at 12:26 PM, palmeida wrote: > > Hi, > > I'm running a test that fails when using Django's TestCase class, but > not when running TestCase from unittest. This is my test class: > > class LoggedInUser(TestCase): >fixtures = ['myflow'] Note fixtures will not be loaded when

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Paulo Almeida
Hi Alex, When I do that I get a 404 instead of a 302. I also tried changing urls.py to have a trailing slash but that also gives me a 404. Byt the way, one of the variables I get in response.context is: {'request_path': u'/myflow/experiment/1/'} Thanks for the reply, Paulo On Tue, Aug 4, 2009 at

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Alex Gaynor
On Tue, Aug 4, 2009 at 11:26 AM, palmeida wrote: > > Hi, > > I'm running a test that fails when using Django's TestCase class, but > not when running TestCase from unittest. This is my test class: > > class LoggedInUser(TestCase): >    fixtures = ['myflow'] >    def setUp(self): >        self.clie

Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread palmeida
Hi, I'm running a test that fails when using Django's TestCase class, but not when running TestCase from unittest. This is my test class: class LoggedInUser(TestCase): fixtures = ['myflow'] def setUp(self): self.client = Client() try: User.objects.create_user(