python: also catch general c++ exceptions
they might be thrown from third-party code (notably Ogre in the ovis module). While Linux is kind enough to print them, they cause instant termination on Windows. Arguably, they do not origin from OpenCV itself, but still this helps understanding what went wrong when calling an OpenCV function.
This commit is contained in:
@@ -47,6 +47,12 @@ class Bindings(NewOpenCVTests):
|
||||
boost.getMaxDepth() # from ml::DTrees
|
||||
boost.isClassifier() # from ml::StatModel
|
||||
|
||||
def test_raiseGeneralException(self):
|
||||
with self.assertRaises((cv.error,),
|
||||
msg='C++ exception is not propagated to Python in the right way') as cm:
|
||||
cv.utils.testRaiseGeneralException()
|
||||
self.assertEqual(str(cm.exception), 'exception text')
|
||||
|
||||
def test_redirectError(self):
|
||||
try:
|
||||
cv.imshow("", None) # This causes an assert
|
||||
|
||||
Reference in New Issue
Block a user