From: spo Date: Thu, 9 Jun 2016 13:54:13 +0000 (+0300) Subject: Fix TestSketcherSetCoincident::test_none_type_arguments test X-Git-Tag: V_2.4.0~91^2~68 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45e764209557545ba268568db9347e3a8d0203b0;p=modules%2Fshaper.git Fix TestSketcherSetCoincident::test_none_type_arguments test --- diff --git a/src/ModelHighAPI/ModelHighAPI.i b/src/ModelHighAPI/ModelHighAPI.i index 30bb59da3..44a3675a8 100644 --- a/src/ModelHighAPI/ModelHighAPI.i +++ b/src/ModelHighAPI/ModelHighAPI.i @@ -64,6 +64,10 @@ std::shared_ptr * temp_object; int newmem = 0; if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { + if (!temp_attribute) { + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelAPI_Attribute, int or ModelAPI_Object."); + return NULL; + } temp = ModelHighAPI_RefAttr(*temp_attribute); if (newmem & SWIG_CAST_NEW_MEMORY) { delete temp_attribute; @@ -71,6 +75,10 @@ $1 = &temp; } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { + if (!temp_object) { + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelAPI_Attribute, int or ModelAPI_Object."); + return NULL; + } temp = ModelHighAPI_RefAttr(*temp_object); if (newmem & SWIG_CAST_NEW_MEMORY) { delete temp_object; diff --git a/src/PythonAPI/Test/TestSketcherSetCoincident.py b/src/PythonAPI/Test/TestSketcherSetCoincident.py index 09518cf80..a964e59a9 100644 --- a/src/PythonAPI/Test/TestSketcherSetCoincident.py +++ b/src/PythonAPI/Test/TestSketcherSetCoincident.py @@ -9,10 +9,10 @@ class SketcherSetCoincident(SketcherTestCase): self.sketch.setCoincident(l1.endPoint(), l2.startPoint()) model.do() -# def test_none_type_arguments(self): -# l2 = self.sketch.addLine(0, 1, 1, 1) -# with self.assertRaises(TypeError): -# self.sketch.setCoincident(None, l2.startPoint()) + def test_none_type_arguments(self): + l2 = self.sketch.addLine(0, 1, 1, 1) + with self.assertRaises(TypeError): + self.sketch.setCoincident(None, l2.startPoint()) def test_empty_arguments(self): l1 = self.sketch.addLine(0, 0, 0, 1)