changeset 891:ba1b39629510

some whitespace cleanup in the tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 06 Jul 2006 20:50:46 +0200
parents de485daead4a
children 9931a09387b0
files MoinMoin/_tests/__init__.py MoinMoin/_tests/_test_template.py MoinMoin/_tests/test_request.py
diffstat 3 files changed, 37 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/__init__.py	Thu Jul 06 19:52:47 2006 +0200
+++ b/MoinMoin/_tests/__init__.py	Thu Jul 06 20:50:46 2006 +0200
@@ -74,7 +74,7 @@
             def testSomething(self):
                 # test that needs those defaults and custom values
     """
-    
+
     def __init__(self, request, defaults=(), **custom):
         """ Create temporary configuration for a test 
 
@@ -88,7 +88,7 @@
         self.new = []  # New added attributes
         self.setDefaults(defaults)
         self.setCustom(**custom)
-    
+
     def setDefaults(self, defaults=()):
         """ Set default values for keys in defaults list
         
@@ -97,20 +97,20 @@
         from MoinMoin.multiconfig import DefaultConfig
         for key in defaults:
             self._setattr(key, getattr(DefaultConfig, key))
-            
+
     def setCustom(self, **custom):
         """ Set custom values """
         for key, value in custom.items():
             self._setattr(key, value)
-    
+
     def _setattr(self, key, value):
         """ Set a new value for key saving new added keys """
         if hasattr(self.request.cfg, key):
             self.old[key] = getattr(self.request.cfg, key)
         else:
             self.new.append(key)
-        setattr(self.request.cfg, key, value)        
-       
+        setattr(self.request.cfg, key, value)
+
     def __del__(self):
         """ Restore previous request.cfg 
         
@@ -134,8 +134,8 @@
 
     def loadTestsFromTestCase(self, testCaseClass):
         testCaseClass.request = self.request
-        return TestLoader.loadTestsFromTestCase(self, testCaseClass)        
-        
+        return TestLoader.loadTestsFromTestCase(self, testCaseClass)
+
     def loadTestsFromModuleNames(self, names):
         """ Load tests from qualified module names, eg. a.b.c
         
@@ -146,7 +146,7 @@
         suites = []
         for name in names:
             module = __import__(name, globals(), {}, ['dummy'])
-            suites.append(self.loadTestsFromModule(module))    
+            suites.append(self.loadTestsFromModule(module))
         return self.suiteClass(suites)
 
 
@@ -165,7 +165,7 @@
         names = [name for name in names if name.startswith('test_')]
         caseInsensitiveCompare = lambda a, b: cmp(a.lower(), b.lower())
         names.sort(caseInsensitiveCompare)
-    
+
     return MoinTestLoader(request).loadTestsFromModuleNames(names)
 
 
@@ -179,12 +179,13 @@
     if request is None:
         from MoinMoin.request import CLI
         from MoinMoin.user import User
-        request = CLI.Request()   
+        request = CLI.Request()
         request.form = request.args = request.setup_args()
         request.user = User(request)
-        
+
     suite = makeSuite(request, names)
-    
+
     # do not redirect the stream to request here because request.write can
     # be invalid or broken because not all redirections of it use a finally: block
     TextTestRunner(stream=sys.stdout, verbosity=2).run(suite)
+
--- a/MoinMoin/_tests/_test_template.py	Thu Jul 06 19:52:47 2006 +0200
+++ b/MoinMoin/_tests/_test_template.py	Thu Jul 06 20:50:46 2006 +0200
@@ -34,8 +34,8 @@
         expected = 'expected value'
         self.assertEqual(result, expected,
                          ('Expected "%(expected)s" but got "%(result)s"') % locals())
-    
-    
+
+
 class ComplexTestCase(unittest.TestCase):
     """ Describe these tests here...
 
@@ -53,16 +53,16 @@
         Some test needs specific config values, or they will fail.
         """
         self.config = TestConfig(self.request,
-                                 defaults=['this option', 'that option'], 
+                                 defaults=['this option', 'that option'],
                                  another_option='non default value')
-    
+
     def tearDown(self):
         """ Stuff that should run after each test
 
         Delete TestConfig, if used.
-        """       
+        """
         del self.config
-    
+
     def testFunction(self):
         """ module_tested: function should... """
         for description, test, expected in self._tests:
@@ -81,4 +81,3 @@
 
         return result
 
-
--- a/MoinMoin/_tests/test_request.py	Thu Jul 06 19:52:47 2006 +0200
+++ b/MoinMoin/_tests/test_request.py	Thu Jul 06 20:50:46 2006 +0200
@@ -8,18 +8,18 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import unittest 
+import unittest
 from MoinMoin._tests import TestConfig
 from MoinMoin import config
 
 class NormalizePagenameTestCase(unittest.TestCase):
-            
+
     def testPageInvalidChars(self):
         """ request: normalize pagename: remove invalid unicode chars
 
         Assume the default setting
         """
-        test  = u'\u0000\u202a\u202b\u202c\u202d\u202e'
+        test = u'\u0000\u202a\u202b\u202c\u202d\u202e'
         expected = u''
         result = self.request.normalizePagename(test)
         self.assertEqual(result, expected,
@@ -27,7 +27,7 @@
 
     def testNormalizeSlashes(self):
         """ request: normalize pagename: normalize slashes """
-        cases  = (
+        cases = (
             (u'/////', u''),
             (u'/a', u'a'),
             (u'a/', u'a'),
@@ -42,7 +42,7 @@
 
     def testNormalizeWhitespace(self):
         """ request: normalize pagename: normalize whitespace """
-        cases  = (
+        cases = (
             (u'         ', u''),
             (u'    a', u'a'),
             (u'a    ', u'a'),
@@ -63,7 +63,7 @@
         Underscores should convert to spaces, then spaces should be
         normalized, order is important!
         """
-        cases  = (
+        cases = (
             (u'_________', u''),
             (u'__a', u'a'),
             (u'a__', u'a'),
@@ -81,7 +81,7 @@
 
    def setUp(self):
        self.config = TestConfig(self.request,
-                                page_group_regex = r'.+Group')              
+                                page_group_regex=r'.+Group')
 
    def tearDown(self):
        del self.config
@@ -92,8 +92,8 @@
        Spaces should normalize after invalid chars removed!
        """
        import re
-       group = re.compile(r'.+Group', re.UNICODE)       
-       cases  = (
+       group = re.compile(r'.+Group', re.UNICODE)
+       cases = (
            # current acl chars
            (u'Name,:Group', u'NameGroup'),
            # remove than normalize spaces
@@ -112,31 +112,31 @@
 
     def testRFC1123Date(self):
         """ request: httpDate default rfc1123 """
-        self.failUnlessEqual(self.request.httpDate(0), 
+        self.failUnlessEqual(self.request.httpDate(0),
                              'Thu, 01 Jan 1970 00:00:00 GMT',
                              'wrong date string')
 
     def testRFC850Date(self):
         """ request: httpDate rfc850 """
-        self.failUnlessEqual(self.request.httpDate(0, rfc='850'), 
+        self.failUnlessEqual(self.request.httpDate(0, rfc='850'),
                              'Thursday, 01-Jan-70 00:00:00 GMT',
                              'wrong date string')
-                             
+
 
 class GetPageNameFromQueryString(unittest.TestCase):
     """ Test urls like http://netloc/wiki?pagename """
 
     def setUp(self):
         self.savedQuery = self.request.query_string
-    
+
     def tearDown(self):
         self.request.query_string = self.savedQuery
-    
+
     def testAscii(self):
         """ request: getPageNameFromQueryString: ascii """
         name = expected = u'page name'
         self.runTest(name, expected)
-        
+
     def testNonAscii(self):
         """ request: getPageNameFromQueryString: non ascii """
         name = expected = u'דף עברי'
@@ -147,7 +147,7 @@
         name = u'page_name'
         expected = u'page name'
         self.runTest(name, expected)
-        
+
     def runTest(self, name, expected):
         import urllib
         # query as made by most browsers when you type the url into the
@@ -155,3 +155,4 @@
         query = urllib.quote(name.encode('utf-8'))
         self.request.query_string = query
         self.assertEqual(self.request.getPageNameFromQueryString(), expected)
+