From 45e764209557545ba268568db9347e3a8d0203b0 Mon Sep 17 00:00:00 2001 From: spo Date: Thu, 9 Jun 2016 16:54:13 +0300 Subject: [PATCH] Fix TestSketcherSetCoincident::test_none_type_arguments test --- src/ModelHighAPI/ModelHighAPI.i | 8 ++++++++ src/PythonAPI/Test/TestSketcherSetCoincident.py | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) 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) -- 2.39.2