From c21fb01cfcfc47e87366fa5262b06b692b3cc5a4 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 29 Mar 2017 11:36:45 +0300 Subject: [PATCH] Unit tests fixes related to python swigged lists iteration --- src/GeomAPI/GeomAPI.i | 6 ----- src/GeomAlgoAPI/GeomAlgoAPI.i | 3 --- src/Model/Model_Validator.cpp | 27 ------------------- src/ModelAPI/ModelAPI.i | 6 ++--- .../Test/TestCreateCircleByCenterAndPassed.py | 2 ++ 5 files changed, 5 insertions(+), 39 deletions(-) diff --git a/src/GeomAPI/GeomAPI.i b/src/GeomAPI/GeomAPI.i index 872232006..02687c259 100644 --- a/src/GeomAPI/GeomAPI.i +++ b/src/GeomAPI/GeomAPI.i @@ -76,9 +76,3 @@ %include "GeomAPI_XYZ.h" %include "GeomAPI_Trsf.h" %include "GeomAPI_Wire.h" - -%include "std_list.i" -%include "std_set.i" - -%template(PointList) std::list >; -%template(PointSet) std::set >; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI.i b/src/GeomAlgoAPI/GeomAlgoAPI.i index e79c011bd..6ba7fc781 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI.i +++ b/src/GeomAlgoAPI/GeomAlgoAPI.i @@ -2,9 +2,6 @@ %module GeomAlgoAPI %{ #include "GeomAlgoAPI_swig.h" - - // fix for SWIG v2.0.4 - #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj)) %} // import other modules diff --git a/src/Model/Model_Validator.cpp b/src/Model/Model_Validator.cpp index bf126c17b..7314b48aa 100644 --- a/src/Model/Model_Validator.cpp +++ b/src/Model/Model_Validator.cpp @@ -174,11 +174,6 @@ bool Model_ValidatorsFactory::validate(const std::shared_ptr& for(; aValidatorIt != aValidators.cend(); aValidatorIt++) { const std::string& aValidatorID = aValidatorIt->first; const std::list& anArguments = aValidatorIt->second; - // validators() checks invalid validator names - //if (!aValidator) { - // Events_Error::send(std::string("Validator ") + aValidatorID + " was not registered"); - // continue; - //} const ModelAPI_FeatureValidator* aFValidator = dynamic_cast(validator(aValidatorID)); if (aFValidator) { @@ -196,30 +191,8 @@ bool Model_ValidatorsFactory::validate(const std::shared_ptr& } } } - // The default validator was retrned by validators() and was checked in previous cycle - //// check default validator - //std::map::const_iterator aDefaultVal = myIDs.find(kDefaultId); - //if(aDefaultVal != myIDs.end()) { - // static const std::list anEmptyArgList; - // const ModelAPI_FeatureValidator* aFValidator = - // dynamic_cast(aDefaultVal->second); - // if (aFValidator) { - // std::string anError; - // if (!aFValidator->isValid(theFeature, anEmptyArgList, anError)) { - // if (anError.empty()) - // anError = "Unknown error."; - // anError = "Feature invalidated by \"" + kDefaultId + "\" with error: " + anError; - // theFeature->setError(anError, false); - // theFeature->data()->execState(ModelAPI_StateInvalidArgument); - // return false; - // } - // } - //} // check all attributes for validity - // Validity of data is checked by "Model_FeatureValidator" (kDefaultId) - // if (!aData || !aData->isValid()) - // return false; static const std::string kAllTypes = ""; std::list aLtAttributes = aData->attributesIDs(kAllTypes); std::list::const_iterator anAttrIt = aLtAttributes.cbegin(); diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index ab67ad2ae..09cad6cd7 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -10,9 +10,6 @@ %{ #include "ModelAPI_swig.h" - - // fix for SWIG v2.0.4 - #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj)) %} // import other modules @@ -178,5 +175,8 @@ template std::shared_ptr shared_ptr_cast(std::shared_ptr %template(modelAPI_AttributeRefAttrList) shared_ptr_cast; %template(modelAPI_AttributeTables) shared_ptr_cast; +%template(PointList) std::list >; +%template(PointSet) std::set >; + // Geometry casts %template(shapeToEdge) shared_ptr_cast; diff --git a/src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py b/src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py index bb691dfcb..e37ec2f58 100644 --- a/src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py +++ b/src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py @@ -236,7 +236,9 @@ aPassed.setValue(aLineStart[0], aLineStart[1]) aSession.finishOperation() aLastFeature = aSketchFeature.subFeature(aSketchFeature.numberOfSubs() - 1) assert aLastFeature.getKind() == "SketchMacroCircle", "ERROR: SketchMacroCircle has NOT expected to be valid" +aSession.startOperation() aDocument.removeFeature(aCircle) +aSession.finishOperation() assert (aSketchFeature.numberOfSubs() == 10) #========================================================================= -- 2.39.2