Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#10908 closed (fixed)

Information about proper way of user creation for testing

Reported by: Filip Gruszczyński Owned by: nobody
Component: Documentation Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have created user using User.objects.create and then tried Client().login and it constantly fails. The proper way was to user User.objects.create_user, but there was not a word in testing docs! There should be such information. Here is the link: http://docs.djangoproject.com/en/dev/topics/testing/#django.test.client.Client.login

Attachments (2)

docs.patch (671 bytes ) - added by Filip Gruszczyński 15 years ago.
10908.diff (843 bytes ) - added by Tim Graham 15 years ago.
slightly updated patch with links to methods

Download all attachments as: .zip

Change History (10)

comment:1 by Filip Gruszczyński, 15 years ago

Component: UncategorizedDocumentation

in reply to:  description ; comment:2 by Ramiro Morales, 15 years ago

Replying to gruszczy:

I have created user using User.objects.create and then tried Client().login and it constantly fails. The proper way was to user User.objects.create_user, but there was not a word in testing docs! There should be such information. Here is the link: http://docs.djangoproject.com/en/dev/topics/testing/#django.test.client.Client.login

Are you sure you are correctly using create()? This test shows an user can be created without having to resort to use create_user() and the documentation says it is "The most basic way" not that it is the proper or exclusive way to add an user.

in reply to:  2 comment:3 by Tim Graham, 15 years ago

+1. I had this problem recently as well. I think the issue is that using create() doesn't hash the password. I had to use set_password() until I discovered create_user().

comment:4 by Filip Gruszczyński, 15 years ago

I don't know, if it's useful, but I have written this additional line and I am uploading diff.

by Filip Gruszczyński, 15 years ago

Attachment: docs.patch added

comment:5 by Filip Gruszczyński, 15 years ago

Has patch: set

by Tim Graham, 15 years ago

Attachment: 10908.diff added

slightly updated patch with links to methods

comment:6 by Tim Graham, 15 years ago

Triage Stage: UnreviewedReady for checkin
Version: 1.0SVN

comment:7 by Russell Keith-Magee, 15 years ago

Resolution: fixed
Status: newclosed

(In [11248]) Fixed #10908 -- Clarified the procedure for creating test users in the testing docs. Thanks to gruszczy and timo.

comment:8 by Russell Keith-Magee, 15 years ago

(In [11254]) [1.0.X] Fixed #10908 -- Clarified the procedure for creating test users in the testing docs. Thanks to gruszczy and timo.

Merge of r11248 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top