3
>>> from django.contrib.auth.models import User, AnonymousUser
4
>>> u = User.objects.create_user('testuser', 'test@example.com', 'testpw')
5
>>> u.has_usable_password()
7
>>> u.check_password('bad')
9
>>> u.check_password('testpw')
11
>>> u.set_unusable_password()
13
>>> u.check_password('testpw')
15
>>> u.has_usable_password()
17
>>> u2 = User.objects.create_user('testuser2', 'test2@example.com')
18
>>> u2.has_usable_password()
21
>>> u.is_authenticated()
28
>>> a = AnonymousUser()
29
>>> a.is_authenticated()
37
>>> a.user_permissions.all()
41
# Tests for createsuperuser management command.
42
# It's nearly impossible to test the interactive mode -- a command test helper
43
# would be needed (and *awesome*) -- so just test the non-interactive mode.
44
# This covers most of the important validation, but not all.
46
>>> from django.core.management import call_command
48
>>> call_command("createsuperuser", noinput=True, username="joe", email="joe@somewhere.org")
49
Superuser created successfully.
51
>>> u = User.objects.get(username="joe")