From 0e9af4b93ab0b0b0f1ac175db322b4013f3c6c00 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Fri, 19 Oct 2012 23:30:09 +0100 Subject: [PATCH] Clear existing groups before readding, stops people with removed groups persisting --- django-testauth/auth.py | 1 + 1 file changed, 1 insertion(+) diff --git a/django-testauth/auth.py b/django-testauth/auth.py index e42fc9f..ef3c3e3 100644 --- a/django-testauth/auth.py +++ b/django-testauth/auth.py @@ -46,6 +46,7 @@ class TESTAuthBackend: user.save() if getattr(settings, 'TEST_AUTH_CREATE_GROUPS', False): + user.groups.clear() for g in groups: group, created = Group.objects.get_or_create(name=g['name']) user.groups.add(group)