X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FExchangePlugin%2FTest%2FTestExport.py;h=b3fdf14c4df2e34089fa45eba651f754859249e8;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=353e7ea2cceb2066a797cdf54cf47acd57e45b84;hpb=c4eab94a20a0d93100549a210582d46409fec1cc;p=modules%2Fshaper.git diff --git a/src/ExchangePlugin/Test/TestExport.py b/src/ExchangePlugin/Test/TestExport.py old mode 100644 new mode 100755 index 353e7ea2c..b3fdf14c4 --- a/src/ExchangePlugin/Test/TestExport.py +++ b/src/ExchangePlugin/Test/TestExport.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2019 CEA/DEN, EDF R&D +# Copyright (C) 2014-2023 CEA, EDF # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -49,7 +49,7 @@ def removeFile(theFileName): #========================================================================= # Common test function #========================================================================= -def testExport(theType, theFormat, theFile, theVolume, theDelta, theErrorExpected = False): +def testExport(theType, theFormat, theFile, theVolume, theArea, theDelta, theErrorExpected = False): # Import a reference part aSession.startOperation("Add part") aPartFeature = aSession.moduleDocument().addFeature("Part") @@ -59,7 +59,9 @@ def testExport(theType, theFormat, theFile, theVolume, theDelta, theErrorExpecte aSession.startOperation("Import screw") anImportFeature = aPart.addFeature("Import") aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Step", "screw.step") - anImportFeature.string("file_path").setValue(aShapePath) + anImportFeature.string("step_file_path").setValue(aShapePath) + anImportFeature.string("ImportType").setValue("STEP") + anImportFeature.boolean("step_scale_inter_units").setValue(True) aSession.finishOperation() removeFile(theFile) @@ -82,7 +84,7 @@ def testExport(theType, theFormat, theFile, theVolume, theDelta, theErrorExpecte assert os.path.exists(theFile) # Test exported file by importing - testImport(theType, theFile, theVolume, theDelta) + testImport(theType, theFile, theVolume, theArea, theDelta) def testExportXAO(theFile, theEmptyFormat = False): type = "XAO" @@ -101,6 +103,7 @@ def testExportXAO(theFile, theEmptyFormat = False): anImportFeature = aPart.addFeature("Import") aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Brep", "box1.brep") anImportFeature.string("file_path").setValue(aShapePath) + anImportFeature.string("ImportType").setValue("BREP") aSession.finishOperation() # Create groups @@ -157,8 +160,15 @@ def testExportXAO(theFile, theEmptyFormat = False): # Check exported file aRefPath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Xao", "box2.xao") - import filecmp - assert filecmp.cmp(theFile, aRefPath) + # endlines may be different on different platforms, thus compare files line-by-line + areFilesEqual = True + with open(theFile, 'r') as file, open(aRefPath, 'r') as ref: + l1 = l2 = True + while l1 and l2 and areFilesEqual: + l1 = file.readline() + l2 = ref.readline() + areFilesEqual = l1 == l2 + assert areFilesEqual if __name__ == '__main__': with TemporaryDirectory() as tmp_dir: @@ -166,23 +176,23 @@ if __name__ == '__main__': # Export a shape into BREP #========================================================================= aRealVolume = 3.78827401738e-06 - testExport("BREP", "BREP", os.path.join(tmp_dir, "screw_export.brep"), aRealVolume, 10 ** -17) - testExport("BRP", "BREP", os.path.join(tmp_dir, "screw_export.brp"), aRealVolume, 10 ** -17) - testExport("Regular", "", os.path.join(tmp_dir, "screw_export.brep"), aRealVolume, 10 ** -17) + testExport("BREP", "BREP", os.path.join(tmp_dir, "screw_export.brep"), aRealVolume, 0.0019293313778547098, 10 ** -17) + testExport("BRP", "BREP", os.path.join(tmp_dir, "screw_export.brp"), aRealVolume, 0.0019293313778547098, 10 ** -17) + testExport("BREP", "", os.path.join(tmp_dir, "screw_export.brep"), aRealVolume, 0.0019293313778547098, 10 ** -17) #========================================================================= # Export a shape into STEP #========================================================================= - testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.step"), 3.78825807533e-06, 10 ** -17) - testExport("STP", "STEP", os.path.join(tmp_dir, "screw_export.stp"), 3.78825807533e-06, 10 ** -17) - testExport("Regular", "", os.path.join(tmp_dir, "screw_export.step"), 3.78825807533e-06, 10 ** -17) + testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.step"), 3.788258075329978e-06, 0.0019293304476337928, 10 ** -17) + testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.stp"), 3.788258075329978e-06, 0.0019293304476337928, 10 ** -17) + testExport("STEP", "", os.path.join(tmp_dir, "screw_export.step"), 3.788258075329978e-06, 0.0019293304476337928, 10 ** -17) #========================================================================= # Export a shape into IGES #========================================================================= - testExport("IGES-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.iges"), 3.78829613776e-06, 10 ** -17) - testExport("IGS-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.igs"), 3.78829613776e-06, 10 ** -17) - testExport("Regular", "", os.path.join(tmp_dir, "screw_export-5.1.iges"), 3.78829613776e-06, 10 ** -17) - testExport("IGES-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.iges"), 3.78827401651e-06, 10 ** -17) - testExport("IGS-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.igs"), 3.78827401651e-06, 10 ** -17) + testExport("IGES", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0, 0.0019293313766693052, 10 ** -17) + testExport("IGS", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.igs"), 0.0, 0.0019293313766693052, 10 ** -17) + testExport("IGES", "", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0, 0.0019293313766693052, 10 ** -17) + testExport("IGES", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.iges"), 3.78827401651e-06, 0.001929331377591282, 10 ** -17) + testExport("IGS", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.igs"), 3.78827401651e-06, 0.001929331377591282, 10 ** -17) #========================================================================= # Export a shape into XAO #========================================================================= @@ -191,7 +201,7 @@ if __name__ == '__main__': #========================================================================= # Check error when export to unsupported format #========================================================================= - testExport("Regular", "", os.path.join(tmp_dir, "screw_export.dwg"), 3.78825807533e-06, 10 ** -17, True) + testExport("BREP", "", os.path.join(tmp_dir, "screw_export.dwg"), 3.78825807533e-06, 0.0019293313766693052, 10 ** -17, True) #========================================================================= # End of test #=========================================================================