"""
if "testNbResults" in theTestsList or len(theTestsList) == 0:
aNbResults = len(theFeature.results())
- print "model.testNbResults({}, {})".format(theFeatureName, aNbResults)
+ print("model.testNbResults({}, {})".format(theFeatureName, aNbResults))
if "testNbSubResults" in theTestsList or len(theTestsList) == 0:
aNbResults = len(theFeature.results())
aNbSubResults = []
for anIndex in range(0, aNbResults):
aNbSubResults.append(theFeature.results()[anIndex].numberOfSubs())
- print "model.testNbSubResults({}, {})".format(theFeatureName, aNbSubResults)
+ print("model.testNbSubResults({}, {})".format(theFeatureName, aNbSubResults))
if "testNbSubShapes" in theTestsList or len(theTestsList) == 0:
aNbResults = len(theFeature.results())
aShapeExplorer = GeomAPI_ShapeExplorer(aShape, aShapeType)
while aShapeExplorer.more():
aNbResultSubShapes += 1
- aShapeExplorer.next();
+ aShapeExplorer.next()
aNbSubShapes.append(aNbResultSubShapes)
- print "model.testNbSubShapes({}, {}, {})".format(theFeatureName, aShapeTypes[aShapeType], aNbSubShapes)
+ print("model.testNbSubShapes({}, {}, {})".format(theFeatureName, aShapeTypes[aShapeType], aNbSubShapes))
if "testResultsVolumes" in theTestsList or len(theTestsList) == 0:
aNbResults = len(theFeature.results())
aResultsVolumes = []
for anIndex in range(0, aNbResults):
aResultsVolumes.append(GeomAlgoAPI_ShapeTools_volume(theFeature.results()[anIndex].resultSubShapePair()[0].shape()))
- print "model.testResultsVolumes({}, [{}])".format(theFeatureName, ", ".join("{:0.27f}".format(i) for i in aResultsVolumes))
+ print("model.testResultsVolumes({}, [{}])".format(theFeatureName, ", ".join("{:0.27f}".format(i) for i in aResultsVolumes)))
def testNbResults(theFeature, theExpectedNbResults):
aShapeExplorer = GeomAPI_ShapeExplorer(aShape, theShapeType)
while aShapeExplorer.more():
aNbResultSubShapes += 1
- aShapeExplorer.next();
+ aShapeExplorer.next()
assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
aResultVolumeStr = "{:0.27f}".format(aResultVolume).lstrip("0").lstrip(".").lstrip("0")
anExpectedResultVolume = theExpectedResultsVolumes[anIndex]
anExpectedResultVolumeStr = "{:0.27f}".format(anExpectedResultVolume).lstrip("0").lstrip(".").lstrip("0")
- assert math.fabs(aResultVolume - anExpectedResultVolume) < aTolerance * anExpectedResultVolume, "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits)
+ assert math.fabs(aResultVolume - anExpectedResultVolume) < aTolerance * math.fabs(anExpectedResultVolume), "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits)
def testHaveNamingFaces(theFeature, theModel, thePartDoc) :
""" Tests if all faces of result have a name
""" Tests if all vertices/edges/faces of result have a unique name
:param theFeature: feature to test.
"""
+ assert(len(theFeature.results()) > 0)
testHaveNamingByType(theFeature, theModel, thePartDoc, GeomAPI_Shape.VERTEX)
testHaveNamingByType(theFeature, theModel, thePartDoc, GeomAPI_Shape.EDGE)
testHaveNamingByType(theFeature, theModel, thePartDoc, GeomAPI_Shape.FACE)
theModel.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, NbEdge)
theModel.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, NbVertex)
-def checkSketch(theSketch, theDOF = -1):
- """ Tests the sketch is valid and DoF is equal to the given
- """
- assert(theSketch.feature().error() == ""), "Sketch failed: {}".format(theSketch.feature().error())
- assert(theSketch.solverError().value() == ""), "Sketch solver failed: {}".format(theSketch.solverError().value())
- if theDOF != -1:
- aDOF = sketcher.tools.dof(theSketch)
- assert(aDOF == theDOF), "Sketch DoF {} is wrong. Expected {}".format(aDOF, theDOF)
-
def checkGroup(theGroup, theShapeType):
""" Check that all selected shapes in group have correct shape type and unique name
"""