Changed the auth_backend tests in a cosmteic fashion so that they pass under Python 2.3 as well.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6552 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-10-20 08:15:42 +00:00
parent a0fdd7c7dd
commit cb38521487
1 changed files with 18 additions and 12 deletions

View File

@ -1,4 +1,9 @@
""" try:
set
except NameError:
from sets import Set as set # Python 2.3 fallback
__test__ = {'API_TESTS': """
>>> from django.contrib.auth.models import User, Group, Permission >>> from django.contrib.auth.models import User, Group, Permission
>>> from django.contrib.contenttypes.models import ContentType >>> from django.contrib.contenttypes.models import ContentType
@ -28,10 +33,10 @@ False
# reloading user to purge the _perm_cache # reloading user to purge the _perm_cache
>>> user = User.objects.get(username="test") >>> user = User.objects.get(username="test")
>>> user.get_all_permissions() >>> user.get_all_permissions() == set([u'auth.test'])
set([u'auth.test']) True
>>> user.get_group_permissions() >>> user.get_group_permissions() == set([])
set([]) True
>>> user.has_module_perms("Group") >>> user.has_module_perms("Group")
False False
>>> user.has_module_perms("auth") >>> user.has_module_perms("auth")
@ -43,8 +48,8 @@ True
>>> user.user_permissions.add(perm) >>> user.user_permissions.add(perm)
>>> user.save() >>> user.save()
>>> user = User.objects.get(username="test") >>> user = User.objects.get(username="test")
>>> user.get_all_permissions() >>> user.get_all_permissions() == set([u'auth.test2', u'auth.test', u'auth.test3'])
set([u'auth.test2', u'auth.test', u'auth.test3']) True
>>> user.has_perm('test') >>> user.has_perm('test')
False False
>>> user.has_perm('auth.test') >>> user.has_perm('auth.test')
@ -57,10 +62,11 @@ True
>>> group.save() >>> group.save()
>>> user.groups.add(group) >>> user.groups.add(group)
>>> user = User.objects.get(username="test") >>> user = User.objects.get(username="test")
>>> user.get_all_permissions() >>> exp = set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group'])
set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group']) >>> user.get_all_permissions() == exp
>>> user.get_group_permissions() True
set([u'auth.test_group']) >>> user.get_group_permissions() == set([u'auth.test_group'])
True
>>> user.has_perms(['auth.test3', 'auth.test_group']) >>> user.has_perms(['auth.test3', 'auth.test_group'])
True True
""" """}