diff MoinMoin/_tests/test_user.py @ 892:9931a09387b0

some whitespace cleanup in the tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 06 Jul 2006 21:16:28 +0200
parents 1314fdb74689
children 0d2f2d531e81
line wrap: on
line diff
--- a/MoinMoin/_tests/test_user.py	Thu Jul 06 20:50:46 2006 +0200
+++ b/MoinMoin/_tests/test_user.py	Thu Jul 06 21:16:28 2006 +0200
@@ -20,7 +20,7 @@
         """user: encode ascii password"""
         # u'MoinMoin' and 'MoinMoin' should be encoded to same result
         expected = "{SHA}X+lk6KR7JuJEH43YnmettCwICdU="
-        
+
         result = user.encodePassword("MoinMoin")
         self.assertEqual(result, expected,
                          'Expected "%(expected)s" but got "%(result)s"' % locals())
@@ -43,7 +43,7 @@
         # Save original user and cookie
         self.saved_cookie = self.request.saved_cookie
         self.saved_user = self.request.user
-        
+
         # Create anon user for the tests
         self.request.saved_cookie = ''
         self.request.user = user.User(self.request)
@@ -54,7 +54,7 @@
             del dircache.cache[self.request.cfg.user_dir]
         except KeyError:
             pass
-        
+
     def tearDown(self):
         """ Run after each test
         
@@ -72,25 +72,25 @@
         # Restore original user
         self.request.saved_cookie = self.saved_cookie
         self.request.user = self.saved_user
-                
+
         # Remove user name to id cache, or next test will fail
         caching.CacheEntry(self.request, 'user', 'name2id', scope='wiki').remove()
         del self.request.cfg._name2id
-        
+
         # Prevent user list caching - we create and delete users too
         # fast for that.
         try:
             del dircache.cache[self.request.cfg.user_dir]
         except KeyError:
             pass
-              
+
     def testAsciiPassword(self):
         """ user: login with ascii password """
         # Create test user
         name = u'__Non Existent User Name__'
         password = name
         self.createUser(name, password)
-        
+
         # Try to "login"           
         theUser = user.User(self.request, name=name, password=password)
         self.failUnless(theUser.valid, "Can't login with ascii password")
@@ -101,7 +101,7 @@
         name = u'__שם משתמש לא קיים__' # Hebrew
         password = name
         self.createUser(name, password)
-        
+
         # Try to "login"
         theUser = user.User(self.request, name=name, password=password)
         self.failUnless(theUser.valid, "Can't login with unicode password")
@@ -119,7 +119,7 @@
         name = u'__Jürgen Herman__'
         password = name
         self.createUser(name, password, charset='iso-8859-1')
-        
+
         # Try to "login"           
         theUser = user.User(self.request, name=name, password=password)
         self.failUnless(theUser.valid, "Can't login with old unicode password")
@@ -136,7 +136,6 @@
         name = u'__Jürgen Herman__'
         password = name
         self.createUser(name, password, charset='iso-8859-1')
-        
         # Login - this should replace the old password in the user file         
         theUser = user.User(self.request, name=name, password=password)
         # Login again - the password should be new unicode password
@@ -144,61 +143,61 @@
         theUser = user.User(self.request, name=name, password=password)
         self.assertEqual(theUser.enc_password, expected,
                          "User password was not replaced with new")
-            
+
     # Helpers ---------------------------------------------------------
-    
+
     def createUser(self, name, password, charset='utf-8'):
         """ helper to create test user 
         
         charset is used to create user with pre 1.3 password hash
         """
         # Hack self.request form to contain the password
-        self.request.form['password'] = [password]  
-        
+        self.request.form['password'] = [password]
+
         # Create user
         self.user = user.User(self.request)
         self.user.name = name
         self.user.enc_password = user.encodePassword(password, charset=charset)
-        
+
         # Validate that we are not modifying existing user data file!
         if self.user.exists():
             self.user = None
             raise TestsSkiped("Test user exists, will not override existing"
                               " user data file!")
-        
+
         # Save test user
         self.user.save()
-        
+
         # Validate user creation
         if not self.user.exists():
             self.user = None
             raise TestsSkiped("Can't create test user")
-                        
+
 
 class GroupNameTestCase(unittest.TestCase):
 
     def setUp(self):
         self.config = TestConfig(self.request,
-                                 page_group_regex = r'.+Group')              
+                                 page_group_regex=r'.+Group')
 
     def tearDown(self):
         del self.config
 
     import re
     group = re.compile(r'.+Group', re.UNICODE)
-    
+
     def testGroupNames(self):
-        """ user: isValidName: reject group names """   
+        """ user: isValidName: reject group names """
         test = u'AdminGroup'
         assert self.group.search(test)
         result = user.isValidName(self.request, test)
         expected = False
         self.assertEqual(result, expected,
-                        'Expected "%(expected)s" but got "%(result)s"' % locals()) 
-            
+                        'Expected "%(expected)s" but got "%(result)s"' % locals())
+
 
 class IsValidNameTestCase(unittest.TestCase):
-    
+
     def testNonAlnumCharacters(self):
         """ user: isValidName: reject unicode non alpha numeric characters
 
@@ -209,9 +208,9 @@
         expected = False
         for c in invalid:
             name = base % c
-            result = user.isValidName(self.request, name)           
+            result = user.isValidName(self.request, name)
         self.assertEqual(result, expected,
-                         'Expected "%(expected)s" but got "%(result)s"' % locals()) 
+                         'Expected "%(expected)s" but got "%(result)s"' % locals())
 
     def testWhitespace(self):
         """ user: isValidName: reject leading, trailing or multiple whitespace """
@@ -222,7 +221,7 @@
             )
         expected = False
         for test in cases:
-            result = user.isValidName(self.request, test)          
+            result = user.isValidName(self.request, test)
             self.assertEqual(result, expected,
                          'Expected "%(expected)s" but got "%(result)s"' % locals())
 
@@ -236,8 +235,7 @@
             )
         expected = True
         for test in cases:
-            result = user.isValidName(self.request, test)          
+            result = user.isValidName(self.request, test)
             self.assertEqual(result, expected,
                              'Expected "%(expected)s" but got "%(result)s"' % locals())
 
-