Refs #23947 -- Made a modeladmin test cleanup after itself.

This commit is contained in:
Diego Guimarães 2014-12-05 12:25:10 -02:00 committed by Tim Graham
parent ebfadb8080
commit d05709821c
1 changed files with 12 additions and 7 deletions

View File

@ -1625,10 +1625,15 @@ class ModelAdminPermissionTests(TestCase):
self.assertTrue(ma.has_module_permission(request)) self.assertTrue(ma.has_module_permission(request))
request.user = self.MockDeleteUser() request.user = self.MockDeleteUser()
self.assertTrue(ma.has_module_permission(request)) self.assertTrue(ma.has_module_permission(request))
ma.opts.app_label = "anotherapp"
request.user = self.MockAddUser() original_app_label = ma.opts.app_label
self.assertFalse(ma.has_module_permission(request)) ma.opts.app_label = 'anotherapp'
request.user = self.MockChangeUser() try:
self.assertFalse(ma.has_module_permission(request)) request.user = self.MockAddUser()
request.user = self.MockDeleteUser() self.assertFalse(ma.has_module_permission(request))
self.assertFalse(ma.has_module_permission(request)) request.user = self.MockChangeUser()
self.assertFalse(ma.has_module_permission(request))
request.user = self.MockDeleteUser()
self.assertFalse(ma.has_module_permission(request))
finally:
ma.opts.app_label = original_app_label