From cb38521487832999ac2ec147ab5dc96a96bc25ab Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 20 Oct 2007 08:15:42 +0000 Subject: [PATCH] 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 --- tests/regressiontests/auth_backends/tests.py | 30 ++++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/regressiontests/auth_backends/tests.py b/tests/regressiontests/auth_backends/tests.py index 71e58442e7..3ec2a059ad 100644 --- a/tests/regressiontests/auth_backends/tests.py +++ b/tests/regressiontests/auth_backends/tests.py @@ -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.contenttypes.models import ContentType @@ -28,10 +33,10 @@ False # reloading user to purge the _perm_cache >>> user = User.objects.get(username="test") ->>> user.get_all_permissions() -set([u'auth.test']) ->>> user.get_group_permissions() -set([]) +>>> user.get_all_permissions() == set([u'auth.test']) +True +>>> user.get_group_permissions() == set([]) +True >>> user.has_module_perms("Group") False >>> user.has_module_perms("auth") @@ -43,8 +48,8 @@ True >>> user.user_permissions.add(perm) >>> user.save() >>> user = User.objects.get(username="test") ->>> user.get_all_permissions() -set([u'auth.test2', u'auth.test', u'auth.test3']) +>>> user.get_all_permissions() == set([u'auth.test2', u'auth.test', u'auth.test3']) +True >>> user.has_perm('test') False >>> user.has_perm('auth.test') @@ -57,10 +62,11 @@ True >>> group.save() >>> user.groups.add(group) >>> user = User.objects.get(username="test") ->>> user.get_all_permissions() -set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group']) ->>> user.get_group_permissions() -set([u'auth.test_group']) +>>> exp = set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group']) +>>> user.get_all_permissions() == exp +True +>>> user.get_group_permissions() == set([u'auth.test_group']) +True >>> user.has_perms(['auth.test3', 'auth.test_group']) True -""" \ No newline at end of file +"""}