changeset 644:beabd93b3904 pytest2

removed extra whitespaces form codes, added my name to the tests I wrote
author pkumar <contactprashantat@gmail.com>
date Wed, 13 Jul 2011 00:40:20 +0530
parents c5c41f59a912
children cf6aaf82cccf
files MoinMoin/_tests/test_error.py MoinMoin/_tests/test_user.py MoinMoin/conftest.py MoinMoin/converter/_tests/test_include.py MoinMoin/themes/_tests/test_navi_bar.py MoinMoin/util/_tests/test_crypto.py MoinMoin/util/_tests/test_diff_html.py MoinMoin/util/_tests/test_filesys.py MoinMoin/util/_tests/test_md5crypt.py MoinMoin/util/_tests/test_mime.py MoinMoin/util/_tests/test_mimetype.py MoinMoin/util/_tests/test_thread_monitor.py
diffstat 12 files changed, 70 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_error.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/_tests/test_error.py	Wed Jul 13 00:40:20 2011 +0530
@@ -50,10 +50,10 @@
 
     def setup_method(self, method):
         self.CompositeError_obj = error.CompositeError(error.InternalError)
-        
+
     def teardown_method(self, method):
         self.CompositeError_obj.innerException = None
-        
+
     def test_exceptions(self):
         self.CompositeError_obj.innerException = 'test_error1', 'test_error2', 'test_error3'
         result = error.CompositeError.exceptions(self.CompositeError_obj)
@@ -70,7 +70,7 @@
         self.CompositeError_obj.innerException = str(error.FatalError('This is a fatal Error'))
         result = error.CompositeError.exceptions(self.CompositeError_obj)
         expected = ['This is a fatal Error']
-        assert result == expected         
-    
+        assert result == expected
+
 coverage_modules = ['MoinMoin.error']
 
--- a/MoinMoin/_tests/test_user.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/_tests/test_user.py	Wed Jul 13 00:40:20 2011 +0530
@@ -300,7 +300,7 @@
         assert theuser.email == email
 
     # Bookmarks -------------------------------------------------------
-    
+
     def test_bookmark(self):
         name = u'Test_User_quicklink'
         password = name
@@ -314,15 +314,15 @@
         # delete the bookmark
         result_success = theUser.delBookmark()
         assert result_success == 0
-        result_deleted = theUser.getBookmark()       
+        result_deleted = theUser.getBookmark()
         assert not result_deleted
 
         # delBookmark should return 1 on failure
         result_failure = theUser.delBookmark()
         assert result_failure == 1
-    
+
     # Quicklinks ------------------------------------------------------
-    
+
     def test_quicklinks(self):
         """
         Test for the quicklinks
@@ -334,7 +334,7 @@
         theUser = user.User(name=name, password=password)
         theUser.subscribe(pagename)
 
-        # no quick links exist yet 
+        # no quick links exist yet
         result_before = theUser.getQuickLinks()
         assert result_before == []
 
@@ -351,12 +351,12 @@
         theUser.addQuicklink(u'Test_page_added')
         result_on_addition = theUser.getQuickLinks()
         expected = [u'Test_page_quicklink', u'Test_page_added']
-        assert result_on_addition == expected, ('Expected "%(expected)s" but got "%(result_on_addition)s"') % locals() 
+        assert result_on_addition == expected, ('Expected "%(expected)s" but got "%(result_on_addition)s"') % locals()
 
         # user should be quicklinked to [pagename]
         result = theUser.isQuickLinkedTo([pagename])
         assert result
-        
+
         # previously added page u'Test_page_added' is removed
         theUser.removeQuicklink(u'Test_page_added')
         result_on_removal = theUser.getQuickLinks()
@@ -364,7 +364,7 @@
         assert result_on_removal == expected, ('Expected "%(expected)s" but got "%(result_on_removal)s"') % locals()
 
     # Trail -----------------------------------------------------------
-    
+
     def test_trail(self):
         pagename = u'Test_page_trail'
         name = u'Test_User_trail'
@@ -382,9 +382,9 @@
         result = theUser.getTrail()
         expected = [u'item_added']
         assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()
-        
+
     # Other ----------------------------------------------------------
-    
+
     def test_signature(self):
         name = u'Test_User_other'
         password = name
@@ -396,7 +396,7 @@
         expected =  u'[[Test_User_other]]'
         assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()
 
-    def test_recovery_token(self):            
+    def test_recovery_token(self):
         name = u'Test_User_other'
         password = name
         self.createUser(name, password)
--- a/MoinMoin/conftest.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/conftest.py	Wed Jul 13 00:40:20 2011 +0530
@@ -78,11 +78,11 @@
             if inspect.isclass(self.parent.obj.__class__):
                 cls = self.parent.obj.__class__
 
-                # global variables so that previous values can be accessed            
+                # global variables so that previous values can be accessed
                 global prev_app, prev_ctx, prev_cls
 
                 if hasattr(cls, 'Config'):
-                    if prev_app != None:
+                    if prev_app is not None:
                         # deinit previous app if previous app value is not None.
                         deinit_test_app(prev_app, prev_ctx)
                     given_config = cls.Config
@@ -91,28 +91,28 @@
                 else:
                     given_config = wikiconfig.Config
                     # deinit the previous app if previous class had its own configuration
-                    # deinit the previous app if the class of previous function has an attribute 'create_backend' 
+                    # deinit the previous app if the class of previous function has an attribute 'create_backend'
                     # this is for the tests of storage module until we use some cleanup mechanism on tests.
                     if hasattr(prev_cls, 'Config') or hasattr(prev_cls, 'create_backend'):
                         deinit_test_app(prev_app, prev_ctx)
 
-                    # Initialize the app in following two conditions: 
-                    # 1. It is the first test item 
+                    # Initialize the app in following two conditions:
+                    # 1. It is the first test item
                     # 2. Class of previous function item had its own configuration i.e. hasattr(cls, Config)
-                    # Also if the Class of previous function is having an attribute as 'create_backend', 
+                    # Also if the Class of previous function is having an attribute as 'create_backend',
                     # this is for the tests of storage module until we use some cleanup mechanism on tests.
-                    if prev_app == None or hasattr(prev_cls, 'Config') or hasattr(prev_cls, 'create_backend'):
+                    if prev_app is None or hasattr(prev_cls, 'Config') or hasattr(prev_cls, 'create_backend'):
                         self.app, self.ctx = init_test_app(given_config)
                     # continue assigning the values of the previous app and ctx to the current ones.
                     else:
                         self.app = prev_app
-                        self.ctx = prev_ctx    
+                        self.ctx = prev_ctx
 
                 #Get the values from the function
                 prev_app, prev_ctx, prev_cls = get_previous(self.app, self.ctx, cls)
 
             else:
-                prev_app, prev_ctx, prev_cls = get_previous(None, None, None)            
+                prev_app, prev_ctx, prev_cls = get_previous(None, None, None)
 
             super(MoinTestFunction, self).setup()
             #XXX: hack till we get better funcarg tools
@@ -122,10 +122,10 @@
     finally:
         def teardown(self):
             super(MoinTestFunction, self).teardown()
-        
-    # Need to modify and add more stuffs    
-    
-    
+
+    # Need to modify and add more stuffs
+
+
 def pytest_pycollect_makemodule(path, parent):
     return Module(path, parent=parent)
 
@@ -134,11 +134,11 @@
         return MoinTestFunction(name, parent = collector)
 
 def pytest_pyfunc_call(pyfuncitem):
-    """hook to intercept generators and run them as a single test items"""       
+    """hook to intercept generators and run them as a single test items"""
     if inspect.isgeneratorfunction(pyfuncitem.obj):
         for item in pyfuncitem.obj():
             kwarg = item[1:]
-            item[0](*kwarg)           
+            item[0](*kwarg)
 
 def pytest_report_header(config):
     return "The tests here are implemented only for pytest-2"
--- a/MoinMoin/converter/_tests/test_include.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/converter/_tests/test_include.py	Wed Jul 13 00:40:20 2011 +0530
@@ -47,7 +47,7 @@
     e = x[1]
     assert e.name == 'c'
     assert e.data == 'd'
-    
+
     x = XPointer('a(a(b))')
     assert len(x) == 1
     e = x[0]
--- a/MoinMoin/themes/_tests/test_navi_bar.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/themes/_tests/test_navi_bar.py	Wed Jul 13 00:40:20 2011 +0530
@@ -40,7 +40,7 @@
         test_segment_name_1, test_item_name_1, test_item_exists_1 = test_result[0]
         test_segment_name_2, test_item_name_2, test_item_exists_2 = test_result[1]
         test_segment_name_3, test_item_name_3, test_item_exists_3 = test_result[2]
-         
+
         assert test_segment_name_1 == 'some'
         assert test_item_name_1 == 'some'
         assert test_segment_name_2 == 'place'
@@ -51,18 +51,18 @@
     def test_parent_item(self):
         test_result = ThemeSupport.parent_item(self.theme, 'moin/moin-2.0/Item')
         expected = 'moin/moin-2.0'
-        assert test_result == expected, ('Expected "%(expected)s" but got "%(test_result)s"') % locals()        
+        assert test_result == expected, ('Expected "%(expected)s" but got "%(test_result)s"') % locals()
 
 def test_shorten_item_name():
-    test_result1 = themes.shorten_item_name(u'MoinMoin/some/value', 0) 
-    assert test_result1 == u'valu...lue'    
-    test_result2 = themes.shorten_item_name(u'MoinMoin/some/value', 5) 
-    assert test_result2 == 'value'    
-    test_result3 = themes.shorten_item_name(u'MoinMoin/some/value') 
-    assert test_result3 == u'MoinMoin/some/value'    
+    test_result1 = themes.shorten_item_name(u'MoinMoin/some/value', 0)
+    assert test_result1 == u'valu...lue'
+    test_result2 = themes.shorten_item_name(u'MoinMoin/some/value', 5)
+    assert test_result2 == 'value'
+    test_result3 = themes.shorten_item_name(u'MoinMoin/some/value')
+    assert test_result3 == u'MoinMoin/some/value'
 
 def test_contenttype_to_class():
     test_result = themes.contenttype_to_class(u'MoinMoin/some/value')
-    expected = u'moin-mime-MoinMoin'    
+    expected = u'moin-mime-MoinMoin'
     assert test_result == expected
 
--- a/MoinMoin/util/_tests/test_crypto.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/util/_tests/test_crypto.py	Wed Jul 13 00:40:20 2011 +0530
@@ -47,7 +47,7 @@
         result = crypto.crypt_password(u'סיסמה סודית בהחלט', salt='12345') # Hebrew
         expected = "{SSHA256}pdYvYv+4Vph259sv/HAm7zpZTv4sBKX9ITOX/m00HMsxMjM0NQ=="
         assert result == expected
-    
+
     def testupgradepassword(self):
         """ return new password hash with better hash """
         result = crypto.upgrade_password(u'MoinMoin', "junk_hash")
@@ -60,7 +60,7 @@
         assert result
         with pytest.raises(ValueError):
             invalid_result = crypto.valid_password("MoinMoin", '{junk_value}')
-            
+
 
 class TestToken(object):
     """ tests for the generated tokens """
@@ -70,11 +70,11 @@
         test_key, test_token = crypto.generate_token(key='MoinMoin') # having some key value
         result = crypto.valid_token(test_key, test_token)
         assert result
-        
+
         test_key, test_token = crypto.generate_token() # key value is none
         result = crypto.valid_token(test_key, test_token)
         assert result
-        
+
         test_parts = test_token.split('-')
         test_parts[0] = 'not_valid'
         # changed value of the first part, should not be string
@@ -90,9 +90,9 @@
         """ The key must be different for different <kw> """
         test_kw1 = {'MoinMoin': 'value1'}
         result1 = crypto.cache_key(**test_kw1)
-        test_kw2 = {'Moin2' : 'value2'}
+        test_kw2 = {'Moin2': 'value2'}
         result2 = crypto.cache_key(**test_kw2)
         assert result1 != result2, ("Expected different keys for different <kw> but got the same")
-           
+
 coverage_modules = ['MoinMoin.util.crypto']
 
--- a/MoinMoin/util/_tests/test_diff_html.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/util/_tests/test_diff_html.py	Wed Jul 13 00:40:20 2011 +0530
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright: 2011 by MoinMoin:ThomasWaldmann
+# Copyright: 2011 Prashant Kumar <contactprashantat AT gmail DOT com>
 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
 
 """
@@ -51,8 +51,8 @@
 BBB 100
 """
     result = diff_html.diff(test_input1, test_input2)
-    expected = [(4, '<span><br>AAA 001<br>AAA 002<br>AAA 003<br>AAA 004<br>AAA 005</span>', 
-                 4, '<span>BBB 006<br>BBB 007<br>BBB 008<br>BBB 009<br>BBB 100</span>')]   
+    expected = [(4, '<span><br>AAA 001<br>AAA 002<br>AAA 003<br>AAA 004<br>AAA 005</span>',
+                 4, '<span>BBB 006<br>BBB 007<br>BBB 008<br>BBB 009<br>BBB 100</span>')]
     assert result == expected
 
     #Case 2 : charobj.ratio() > 0.5 i.e. Some similarities
--- a/MoinMoin/util/_tests/test_filesys.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/util/_tests/test_filesys.py	Wed Jul 13 00:40:20 2011 +0530
@@ -143,7 +143,7 @@
         self.test_dir = tempfile.mkdtemp('', 'copytree1')
         self.src1 = os.path.join(self.test_dir, "copytree-src1")
         self.src2 = os.path.join(self.test_dir, "copytree-src2")
-        
+
     def teardown_method(self, method):
         shutil.rmtree(self.test_dir)
         shutil.rmtree(self.test_dest_dir)
@@ -152,14 +152,14 @@
         f = open(src, "w")
         f.write(content)
         f.close()
-        
+
     def test_copytree(self):
         self.makefile(self.src1, 'src1')
         self.makefile(self.src2, 'src2')
         self.test_dest_dir = self.test_dir + '_copy'
         filesys.copytree(self.test_dir, self.test_dest_dir)
         # check for the dir contents
-        assert os.listdir(self.test_dir) == os.listdir(self.test_dest_dir)        
+        assert os.listdir(self.test_dir) == os.listdir(self.test_dest_dir)
 
     def test_dir_exist(self):
         """ raise Error if dir already exist """
--- a/MoinMoin/util/_tests/test_md5crypt.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/util/_tests/test_md5crypt.py	Wed Jul 13 00:40:20 2011 +0530
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright: 2011 by MoinMoin:ThomasWaldmann
+# Copyright: 2011 Prashant Kumar <contactprashantat AT gmail DOT com>
 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
 
 """
--- a/MoinMoin/util/_tests/test_mime.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/util/_tests/test_mime.py	Wed Jul 13 00:40:20 2011 +0530
@@ -29,7 +29,7 @@
     assert i is not t
     assert i == t
     assert i.parameters is not t.parameters
-    
+
 def test_Type_text():
     i = '*/*'
     t = Type(i)
--- a/MoinMoin/util/_tests/test_mimetype.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/util/_tests/test_mimetype.py	Wed Jul 13 00:40:20 2011 +0530
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright: 2011 by MoinMoin:PrashantKumar
+# Copyright: 2011 Prashant Kumar <contactprashantat AT gmail DOT com>
 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
 
 """
@@ -11,7 +11,7 @@
 
 class TestMimeType(object):
     """ Test: util.mimetype """
-    
+
     def test_parse_format(self):
         MimeType_obj = mimetype.MimeType(filename = 'test_file.jpg')
         # format in config.parser_text_mimetype
@@ -23,7 +23,7 @@
         ('latex',       ('text', 'latex'))
         ]
 
-        for test_format, test_mimetype in test: 
+        for test_format, test_mimetype in test:
             result = MimeType_obj.parse_format(test_format)
             assert result == test_mimetype
 
@@ -34,12 +34,12 @@
         ('irc',         ('text', 'irssi')),
         ('test_random', ('text', 'x-test_random'))
         ]
-        
+
         for test_format, test_mimetype in test:
             result = MimeType_obj.parse_format(test_format)
             assert result == test_mimetype
         result = MimeType_obj.parse_format(test_format)
-        
+
     def test_mime_type(self):
         test = [
         # test_extension     # test_major/minor
@@ -48,7 +48,7 @@
         ('.txt',             'text/plain'),
         ('.jpeg',            'image/jpeg')
         ]
-        
+
         # when mimestr is None
         for test_extension, test_major_minor in test:
             MimeType_obj = mimetype.MimeType(filename = 'test_file' + test_extension)
@@ -60,7 +60,7 @@
         MimeType_obj = mimetype.MimeType(filename = 'test_file', mimestr = 'image/jpeg;charset="utf-8";misc=moin_misc')
         result = MimeType_obj.mime_type()
         assert result == 'image/jpeg'
-    
+
     def test_content_type(self):
         MimeType_obj = mimetype.MimeType('test_file.mpeg')
 
@@ -70,11 +70,11 @@
 
         # major == 'text'
         result2 = MimeType_obj.content_type(major = 'text', minor = 'plain', charset="utf-16", params=None)
-        expected = 'text/plain; charset="utf-16"'        
+        expected = 'text/plain; charset="utf-16"'
         assert result2 == expected
 
-        # when all the parameters passed are None 
+        # when all the parameters passed are None
         result3 = MimeType_obj.content_type()
-        expected = 'text/x-test_file.mpeg; charset="utf-8"'        
+        expected = 'text/x-test_file.mpeg; charset="utf-8"'
         assert result3 == expected
-      
+
--- a/MoinMoin/util/_tests/test_thread_monitor.py	Tue Jul 12 19:40:40 2011 +0530
+++ b/MoinMoin/util/_tests/test_thread_monitor.py	Wed Jul 13 00:40:20 2011 +0530
@@ -1,12 +1,12 @@
 # -*- coding: utf-8 -*-
-# Copyright: 2011 by MoinMoin:ThomasWaldmann
+# Copyright: 2011 Prashant Kumar <contactprashantat AT gmail DOT com>
 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
 
 """
 MoinMoin - MoinMoin.util.thread_monitor Tests
 """
 
-import shutil, tempfile 
+import shutil, tempfile
 import os
 
 import pytest
@@ -30,9 +30,9 @@
         # activate the hook
         Monitor_test_obj.activate_hook()
         result_activated = Monitor_test_obj.hook_enabled()
-        assert result_activated     
+        assert result_activated
 
-    def test_trigger_dump(self):        
+    def test_trigger_dump(self):
         """ test for trigger_dump """
         Monitor_test_obj = Monitor()
         # activate the hook first
@@ -43,4 +43,4 @@
         f = open(self.src, "r")
         f.seek(1)
         assert 'Dumping thread' in f.readline()
-        
+