Re: Baffled by self.client.login(...) not working in unit tests

2010-04-19 Thread Ramiro Morales
On Mon, Apr 19, 2010 at 11:51 PM, Brian McKeever  wrote:
> I fixed it by uninstalling Python 2.6.5 and installing 2.6.4 instead.

Then it could be related to a change in behavior introduced
by a [0]fix in the Cookie Python stdlib module included in 2.6.5.

This was reported as ticket [1]12720 in Django and fixed
in revision [2]12343 for the SVN trunk (what will become
Django 1.2) and revision [3]12344 in the 1.1.X (what will
become Django 1.1.2

0. http://bugs.python.org/issue5275
1. http://code.djangoproject.com/ticket/12720
2. http://code.djangoproject.com/changeset/12343
3. http://code.djangoproject.com/changeset/12344

>
> On Apr 19, 8:44 pm, Brian McKeever  wrote:
>> I'm having the same problem. None of my tests are able to log in on
>> this computer.
>>
>> Here's an example:
>>
>>     def test_bug(self):
>>         response = self.client.get(reverse('home'))
>>         self.assertRedirects(response, 'accounts/login/?next=/home/',
>> 302, 200)
>>         bob = User(
>>                 username = 'Bob', email = '@gmail.com')
>>
>>         bob.set_password('Bob')
>>         bob.save()
>>         assert self.client.login( username = 'Bob', password = 'Bob')
>>         response = self.client.get(reverse('home'))
>>         self.assertRedirects(response, 'accounts/login/?next=/home/',
>> 302, 200)
>>
>> Thistestpasses even though it should log in.
>>
>> I'm on a freshly reformatted XP Pro machine.
>> I'm running Django 1.1.1 and Python 2.6.5
>> My code runs fine on my other machine running ubuntu 9.10, Django
>> 1.1.1, and Python 2.6.4.
>>
>> On Apr 10, 11:36 am, adambossy  wrote:
>>
>>
>>
>> > I forgot to mention: I'm using Django 1.0 on Ubuntu.
>>
>> > On Apr 9, 10:41 pm, adambossy  wrote:
>>
>> > > I have created users for my unit tests in two ways:
>>
>> > > 1) Create a fixture for "auth.user" that looks roughly like this:
>>
>> > >     {
>> > >         "pk": 1,
>> > >         "model": "auth.user",
>> > >         "fields": {
>> > >             "username": "homer",
>> > >             "is_active": 1,
>> > >             "password":
>> > > "sha1$72cd3$4935449e2cd7efb8b3723fb9958fe3bb100a30f2",
>> > >             ...
>> > >         }
>> > >     }
>>
>> > > I've left out the seemingly unimportant parts.
>>
>> > > 2) Use 'create_user' in the setUp function (although I'd rather keep
>> > > everything in my fixtures class):
>>
>> > >       def
>> > > setUp(self):
>> > >               User.objects.create_user('homer', 'ho...@simpson.net',
>> > > 'simpson')
>>
>> > > Note that the password is simpson in both cases.
>>
>> > > I've verified that this info is correctly being loaded into thetest
>> > > database time and time again. I can grab the User object using
>> > > User.objects.get. I can verify the password is correct using
>> > > 'check_password.' The user is active.
>>
>> > > Yet, invariably, self.client.login(username='homer',
>> > > password='simpson') FAILS. I'm baffled as to why. I think I've read
>> > > every single Internet discussion pertaining to this. Can anybody help?
>> > > My login code looks like this:
>>
>> > >                 login = self.client.login(username='homer',
>> > > password='simpson')
>> > >                 self.assertTrue(login)
>>
>> > > Thanks,
>>
>> > > Adam
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group 
>> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>



-- 
Ramiro Morales  |  http://rmorales.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Re: Baffled by self.client.login(...) not working in unit tests

2010-04-19 Thread Russell Keith-Magee
On Tue, Apr 20, 2010 at 10:51 AM, Brian McKeever  wrote:
> I fixed it by uninstalling Python 2.6.5 and installing 2.6.4 instead.

Ah - then I think I know the problem.

Python 2.6.5 made a change to the way cookies are stored which is
subtly incompatible with the test client. This problem has been fixed
in the 1.1.X and trunk branches, but the fix hasn't yet made it into a
formal release.

If you are using 1.1.X and Python 2.6.5, you're going to have problems
with any test activity involving cookies. You either need to downgrade
Python, or use the 1.1.X branch rather than the 1.1.1 release.

A 1.1.2 release (that will include the fix for the problem you
describe) will be made at the same time that we release 1.2 -
hopefully, very very soon.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Re: Baffled by self.client.login(...) not working in unit tests

2010-04-19 Thread Brian McKeever
I fixed it by uninstalling Python 2.6.5 and installing 2.6.4 instead.

On Apr 19, 8:44 pm, Brian McKeever  wrote:
> I'm having the same problem. None of my tests are able to log in on
> this computer.
>
> Here's an example:
>
>     def test_bug(self):
>         response = self.client.get(reverse('home'))
>         self.assertRedirects(response, 'accounts/login/?next=/home/',
> 302, 200)
>         bob = User(
>                 username = 'Bob', email = '@gmail.com')
>
>         bob.set_password('Bob')
>         bob.save()
>         assert self.client.login( username = 'Bob', password = 'Bob')
>         response = self.client.get(reverse('home'))
>         self.assertRedirects(response, 'accounts/login/?next=/home/',
> 302, 200)
>
> Thistestpasses even though it should log in.
>
> I'm on a freshly reformatted XP Pro machine.
> I'm running Django 1.1.1 and Python 2.6.5
> My code runs fine on my other machine running ubuntu 9.10, Django
> 1.1.1, and Python 2.6.4.
>
> On Apr 10, 11:36 am, adambossy  wrote:
>
>
>
> > I forgot to mention: I'm using Django 1.0 on Ubuntu.
>
> > On Apr 9, 10:41 pm, adambossy  wrote:
>
> > > I have created users for my unit tests in two ways:
>
> > > 1) Create a fixture for "auth.user" that looks roughly like this:
>
> > >     {
> > >         "pk": 1,
> > >         "model": "auth.user",
> > >         "fields": {
> > >             "username": "homer",
> > >             "is_active": 1,
> > >             "password":
> > > "sha1$72cd3$4935449e2cd7efb8b3723fb9958fe3bb100a30f2",
> > >             ...
> > >         }
> > >     }
>
> > > I've left out the seemingly unimportant parts.
>
> > > 2) Use 'create_user' in the setUp function (although I'd rather keep
> > > everything in my fixtures class):
>
> > >       def
> > > setUp(self):
> > >               User.objects.create_user('homer', 'ho...@simpson.net',
> > > 'simpson')
>
> > > Note that the password is simpson in both cases.
>
> > > I've verified that this info is correctly being loaded into thetest
> > > database time and time again. I can grab the User object using
> > > User.objects.get. I can verify the password is correct using
> > > 'check_password.' The user is active.
>
> > > Yet, invariably, self.client.login(username='homer',
> > > password='simpson') FAILS. I'm baffled as to why. I think I've read
> > > every single Internet discussion pertaining to this. Can anybody help?
> > > My login code looks like this:
>
> > >                 login = self.client.login(username='homer',
> > > password='simpson')
> > >                 self.assertTrue(login)
>
> > > Thanks,
>
> > > Adam
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Re: Baffled by self.client.login(...) not working in unit tests

2010-04-19 Thread Brian McKeever
I'm having the same problem. None of my tests are able to log in on
this computer.

Here's an example:

def test_bug(self):
response = self.client.get(reverse('home'))
self.assertRedirects(response, 'accounts/login/?next=/home/',
302, 200)
bob = User(
username = 'Bob', email = 'b...@gmail.com')

bob.set_password('Bob')
bob.save()
assert self.client.login( username = 'Bob', password = 'Bob')
response = self.client.get(reverse('home'))
self.assertRedirects(response, 'accounts/login/?next=/home/',
302, 200)

This test passes even though it should log in.

I'm on a freshly reformatted XP Pro machine.
I'm running Django 1.1.1 and Python 2.6.5
My code runs fine on my other machine running ubuntu 9.10, Django
1.1.1, and Python 2.6.4.

On Apr 10, 11:36 am, adambossy  wrote:
> I forgot to mention: I'm using Django 1.0 on Ubuntu.
>
> On Apr 9, 10:41 pm, adambossy  wrote:
>
> > I have created users for my unit tests in two ways:
>
> > 1) Create a fixture for "auth.user" that looks roughly like this:
>
> >     {
> >         "pk": 1,
> >         "model": "auth.user",
> >         "fields": {
> >             "username": "homer",
> >             "is_active": 1,
> >             "password":
> > "sha1$72cd3$4935449e2cd7efb8b3723fb9958fe3bb100a30f2",
> >             ...
> >         }
> >     }
>
> > I've left out the seemingly unimportant parts.
>
> > 2) Use 'create_user' in the setUp function (although I'd rather keep
> > everything in my fixtures class):
>
> >       def
> > setUp(self):
> >               User.objects.create_user('homer', 'ho...@simpson.net',
> > 'simpson')
>
> > Note that the password is simpson in both cases.
>
> > I've verified that this info is correctly being loaded into thetest
> > database time and time again. I can grab the User object using
> > User.objects.get. I can verify the password is correct using
> > 'check_password.' The user is active.
>
> > Yet, invariably, self.client.login(username='homer',
> > password='simpson') FAILS. I'm baffled as to why. I think I've read
> > every single Internet discussion pertaining to this. Can anybody help?
> > My login code looks like this:
>
> >                 login = self.client.login(username='homer',
> > password='simpson')
> >                 self.assertTrue(login)
>
> > Thanks,
>
> > Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Re: Baffled by self.client.login(...) not working in unit tests

2010-04-10 Thread adambossy
I forgot to mention: I'm using Django 1.0 on Ubuntu.


On Apr 9, 10:41 pm, adambossy  wrote:
> I have created users for my unit tests in two ways:
>
> 1) Create a fixture for "auth.user" that looks roughly like this:
>
>     {
>         "pk": 1,
>         "model": "auth.user",
>         "fields": {
>             "username": "homer",
>             "is_active": 1,
>             "password":
> "sha1$72cd3$4935449e2cd7efb8b3723fb9958fe3bb100a30f2",
>             ...
>         }
>     }
>
> I've left out the seemingly unimportant parts.
>
> 2) Use 'create_user' in the setUp function (although I'd rather keep
> everything in my fixtures class):
>
>       def
> setUp(self):
>               User.objects.create_user('homer', 'ho...@simpson.net',
> 'simpson')
>
> Note that the password is simpson in both cases.
>
> I've verified that this info is correctly being loaded into the test
> database time and time again. I can grab the User object using
> User.objects.get. I can verify the password is correct using
> 'check_password.' The user is active.
>
> Yet, invariably, self.client.login(username='homer',
> password='simpson') FAILS. I'm baffled as to why. I think I've read
> every single Internet discussion pertaining to this. Can anybody help?
> My login code looks like this:
>
>                 login = self.client.login(username='homer',
> password='simpson')
>                 self.assertTrue(login)
>
> Thanks,
>
> Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.