diff MoinMoin/_tests/test_pysupport.py @ 51:54d5932d5a03

merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action Patches applied: * arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-930 fix error handling in plugins, fix broken chart action * nirs@freeshell.org--2005/moin--fix--1.3--patch-50 merge from main * nirs@freeshell.org--2005/moin--fix--1.3--patch-51 fix error handling in plugins * nirs@freeshell.org--2005/moin--fix--1.3--patch-52 merge from main * nirs@freeshell.org--2005/moin--fix--1.3--patch-53 update changes with chart action fix imported from: moin--main--1.5--patch-52
author Nir Soffer <nirs@freeshell.org>
date Thu, 29 Sep 2005 00:36:27 +0000
parents 77665d8e2254
children 016a8a3ef354
line wrap: on
line diff
--- a/MoinMoin/_tests/test_pysupport.py	Thu Sep 29 00:09:43 2005 +0000
+++ b/MoinMoin/_tests/test_pysupport.py	Thu Sep 29 00:36:27 2005 +0000
@@ -18,19 +18,21 @@
     not broken.
     """
 
-    def testNonExisting(self):
-        """ pysupport: import nonexistent moin plugin fail """
-        self.failIf(pysupport.importName('MoinMoin.parser.abcdefghijkl',
-                                         'Parser'))
+    def testNonExistingModule(self):
+        """ pysupport: import nonexistent module raises ImportError """
+        self.assertRaises(ImportError, pysupport.importName,
+                          'MoinMoin.parser.abcdefghijkl','Parser')
+
+    def testNonExistingAttribute(self):
+        """ pysupport: import nonexistent attritbue raises AttributeError """
+        self.assertRaises(AttributeError, pysupport.importName,
+                          'MoinMoin.parser.wiki','NoSuchParser')
 
     def testExisting(self):
-        """ pysupport: import existing moin plugin
-        
-        This tests if a module can be imported from the package
-        MoinMoin. Should never fail!
-        """
-        self.failUnless(pysupport.importName('MoinMoin.parser.wiki',
-                                             'Parser'))
+        """ pysupport: import name from existing module """
+        from MoinMoin.parser import wiki
+        Parser = pysupport.importName('MoinMoin.parser.wiki', 'Parser')
+        self.failUnless(Parser is wiki.Parser)
    
 
 class ImportNameFromPlugin(unittest.TestCase):
@@ -67,7 +69,8 @@
         """ pysupport: import nonexistent wiki plugin fail """
         if self.pluginExists():
             raise TestSkiped('plugin exists: %s' % self.plugin)
-        self.failIf(pysupport.importName(self.pluginModule, self.name))
+        self.assertRaises(ImportError, pysupport.importName,
+                          self.pluginModule, self.name)
 
 
 class ImportExisting(ImportNameFromPlugin):