[OTHER] Catch only Exception, not BaseException
This commit is contained in:
@@ -37,7 +37,7 @@ class ConsoleTestCase(unittest.TestCase):
|
||||
# http://python-kurs.eu/threads.php
|
||||
try:
|
||||
import _thread as thread, time
|
||||
except:
|
||||
except Exception:
|
||||
import thread, time
|
||||
def adder():
|
||||
lock.acquire()
|
||||
@@ -58,7 +58,7 @@ class ConsoleTestCase(unittest.TestCase):
|
||||
# http://python-kurs.eu/threads.php
|
||||
try:
|
||||
import _thread as thread, time
|
||||
except:
|
||||
except Exception:
|
||||
import thread, time
|
||||
def adder():
|
||||
self.count=self.count+1
|
||||
|
||||
@@ -122,7 +122,7 @@ class DocumentBasicCases(unittest.TestCase):
|
||||
# test read only mechanismus
|
||||
try:
|
||||
self.Doc.UndoCount = 3
|
||||
except:
|
||||
except Exception:
|
||||
FreeCAD.Console.PrintLog(" exception thrown, OK\n")
|
||||
else:
|
||||
self.fail("no exception thrown")
|
||||
@@ -167,7 +167,7 @@ class DocumentBasicCases(unittest.TestCase):
|
||||
self.failUnless(L1.Enum == "Two", "Different value to 'Two'")
|
||||
try:
|
||||
L1.Enum = "SurelyNotInThere!"
|
||||
except:
|
||||
except Exception:
|
||||
FreeCAD.Console.PrintLog(" exception thrown, OK\n")
|
||||
else:
|
||||
self.fail("no exception thrown")
|
||||
@@ -218,7 +218,7 @@ class DocumentBasicCases(unittest.TestCase):
|
||||
self.Doc.removeObject(L1.Name)
|
||||
try:
|
||||
L1.Name
|
||||
except:
|
||||
except Exception:
|
||||
self.failUnless(True)
|
||||
else:
|
||||
self.failUnless(False)
|
||||
@@ -232,7 +232,7 @@ class DocumentBasicCases(unittest.TestCase):
|
||||
self.Doc.undo()
|
||||
try:
|
||||
L2.Name
|
||||
except:
|
||||
except Exception:
|
||||
self.failUnless(True)
|
||||
else:
|
||||
self.failUnless(False)
|
||||
@@ -251,7 +251,7 @@ class DocumentBasicCases(unittest.TestCase):
|
||||
grp.addObject(obj)
|
||||
self.failUnless(len(grp.Group) == 1)
|
||||
self.failUnless(grp.Group[0] == obj)
|
||||
except:
|
||||
except Exception:
|
||||
self.failUnless(False)
|
||||
|
||||
#test if the method override works
|
||||
@@ -268,7 +268,7 @@ class DocumentBasicCases(unittest.TestCase):
|
||||
self.failUnless(grp2.hasExtension("App::GroupExtension"))
|
||||
grp2.addObject(obj)
|
||||
self.failUnless(len(grp2.Group) == 0)
|
||||
except:
|
||||
except Exception:
|
||||
self.failUnless(True)
|
||||
|
||||
self.Doc.removeObject(grp.Name)
|
||||
@@ -456,7 +456,7 @@ class DocumentSaveRestoreCases(unittest.TestCase):
|
||||
Active = FreeCAD.activeDocument()
|
||||
# Second is still a valid object
|
||||
self.failUnless(Second != Active)
|
||||
except:
|
||||
except Exception:
|
||||
# Okay, no document open
|
||||
self.failUnless(True)
|
||||
|
||||
@@ -925,7 +925,7 @@ class DocumentGroupCases(unittest.TestCase):
|
||||
# Adding the group to itself must fail
|
||||
try:
|
||||
G1.addObject(G1)
|
||||
except:
|
||||
except Exception:
|
||||
FreeCAD.Console.PrintLog("Cannot add group to itself, OK\n")
|
||||
else:
|
||||
self.fail("Adding the group to itself must not be possible")
|
||||
@@ -1027,7 +1027,7 @@ class DocumentGroupCases(unittest.TestCase):
|
||||
grp = prt1.Group
|
||||
grp.append(obj1)
|
||||
prt1.Group = grp
|
||||
except:
|
||||
except Exception:
|
||||
grp.remove(obj1)
|
||||
self.failUnless(prt1.Group == grp)
|
||||
else:
|
||||
@@ -1039,7 +1039,7 @@ class DocumentGroupCases(unittest.TestCase):
|
||||
grp.append(obj1)
|
||||
try:
|
||||
grp1.Group = grp
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
self.fail("No exception thrown when object is in multiple Groups")
|
||||
@@ -1080,7 +1080,7 @@ class DocumentGroupCases(unittest.TestCase):
|
||||
prt2.Group = []
|
||||
try:
|
||||
prt2.Group = [prt2]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
self.fail("Exception is expected")
|
||||
@@ -1167,7 +1167,7 @@ class DocumentPlatformCases(unittest.TestCase):
|
||||
self.Doc = FreeCAD.open(self.DocName)
|
||||
|
||||
self.failUnless(self.Doc.Points.Points.count() == 0)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
@@ -77,7 +77,7 @@ class BaseGUITestRunner:
|
||||
self.__rollbackImporter = RollbackImporter()
|
||||
try:
|
||||
test = unittest.defaultTestLoader.loadTestsFromName(testName)
|
||||
except:
|
||||
except Exception:
|
||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||
#apply(traceback.print_exception,sys.exc_info())
|
||||
traceback.print_exception(*sys.exc_info())
|
||||
|
||||
@@ -73,7 +73,7 @@ class BaseGUITestRunner:
|
||||
self.__rollbackImporter = RollbackImporter()
|
||||
try:
|
||||
test = unittest.defaultTestLoader.loadTestsFromName(testName)
|
||||
except:
|
||||
except Exception:
|
||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||
traceback.print_exception(*sys.exc_info())
|
||||
self.errorDialog("Unable to run test '%s'" % testName,
|
||||
|
||||
Reference in New Issue
Block a user