@@ -262,9 +262,10 @@ def testImportFunc(self):
262262 with self .settings (LDAP_AUTH_SYNC_USER_RELATIONS = 'django.contrib.auth.get_user_model' ):
263263 self .assertTrue (callable (import_func (settings .LDAP_AUTH_SYNC_USER_RELATIONS )))
264264
265- # User cleaning.
266-
267265 def testCleanUsersDeactivate (self ):
266+ """
267+ ldap_clean_users management command test
268+ """
268269 from django .contrib .auth import get_user_model
269270 User = get_user_model ()
270271 _username = "nonldap{user}" .format (user = settings .LDAP_AUTH_TEST_USER_USERNAME )
@@ -280,7 +281,9 @@ def testCleanUsersDeactivate(self):
280281 self .assertEqual (user_count_1 , user_count_2 )
281282 self .assertEqual (User .objects .get (username = _username ).is_active , False )
282283
283- ### Test with lookup
284+ """
285+ Test with lookup
286+ """
284287 # Reactivate user
285288 user = User .objects .get (username = _username )
286289 user .is_active = True
@@ -309,12 +312,12 @@ def testCleanUsersDeactivate(self):
309312 self .assertEqual (User .objects .get (username = _username ).is_active , False )
310313 self .assertEqual (User .objects .get (username = _usernameLookup ).is_active , True )
311314 # Lookup a non existing user (raise a CommandError)
312- try :
315+ with self . assertRaises ( CommandError ) :
313316 call_command ("ldap_clean_users" , 'doesnonexist' , verbosity = 0 )
314- except Exception as e :
315- print (e )
316317
317- ### Test with superuser
318+ """
319+ Test with superuser
320+ """
318321 # Reactivate first user and promote to superuser
319322 user = User .objects .get (username = _username )
320323 user .is_active = True
@@ -330,7 +333,9 @@ def testCleanUsersDeactivate(self):
330333 call_command ("ldap_clean_users" , superuser = True , verbosity = 0 )
331334 self .assertEqual (User .objects .get (username = _username ).is_active , False )
332335
333- ### Test with staff user
336+ """
337+ Test with staff user
338+ """
334339 # Reactivate first user and promote to staff
335340 user = User .objects .get (username = _username )
336341 user .is_active = True
@@ -348,6 +353,9 @@ def testCleanUsersDeactivate(self):
348353 self .assertEqual (User .objects .get (username = _username ).is_active , False )
349354
350355 def testCleanUsersPurge (self ):
356+ """
357+ ldap_clean_users management command test with purge argument
358+ """
351359 from django .contrib .auth import get_user_model
352360 User = get_user_model ()
353361 user = User .objects .create_user (
0 commit comments