except:
pass
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'w')
- print("TEST start", file=dbgFile)
- dbgFile.close()
- # ===========================================
proc = Popen([salomeKernelDir + "/bin/salome/runSalome.py", "--modules", "SHAPER,GEOM", "--gui", "--ns-port-log=" + portlogfile, sourceDir + "/test_hdf.py", "args:" + testfile + "," + portlogfile + "," + testlogfile + "," + salomeKernelDir + "," + sourceDir])
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print("TEST Salome started", file=dbgFile)
- dbgFile.close()
- # ===========================================
iter = 0
while not os.path.exists(portlogfile) and iter < 100:
while os.path.exists(portlogfile):
sleep(0.1)
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print("TEST process log file", file=dbgFile)
- dbgFile.close()
- # ===========================================
isOk = True
with open(testlogfile, 'r') as inputFile:
s = inputFile.read()
except:
pass
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print("TEST finished {}".format(isOk), file=dbgFile)
- dbgFile.close()
- # ===========================================
assert isOk, "Test failed"
reffile = ""
def setUp(self):
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest setUp() started", file=dbgFile)
- dbgFile.close()
- # ===========================================
salome.salome_close()
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest previous session closed", file=dbgFile)
- dbgFile.close()
- # ===========================================
# leave file name only (trim path and extension)
fileName = os.path.basename(self.testfile)
self.reffile = self.reffile + "/" + os.path.splitext(fileName)[0] + ".py"
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest reffile: {}".format(self.reffile), file=dbgFile)
- dbgFile.close()
- # ===========================================
salome.salome_init(self.testfile, embedded=1)
myStudyName = salome.myStudy._get_Name()
self.session = salome.naming_service.Resolve('/Kernel/Session')
self.session.emitMessage("connect_to_study")
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest Salome started", file=dbgFile)
- dbgFile.close()
- # ===========================================
self.sg = SalomePyQt.SalomePyQt()
self.sg.activateModule("Shaper")
self.session = ModelAPI.ModelAPI_Session.get()
self.partSet = self.session.moduleDocument()
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest Shaper started", file=dbgFile)
- dbgFile.close()
- # ===========================================
def tearDown(self):
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest tearDown() started", file=dbgFile)
- dbgFile.close()
- # ===========================================
salome.sg.UpdateView()
self.sg.processEvents()
salome.sg.FitAll()
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest tearDown() finished", file=dbgFile)
- dbgFile.close()
- # ===========================================
def test_hdf_file(self):
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest start HDF file testing", file=dbgFile)
- dbgFile.close()
- # ===========================================
self.assertTrue(self.partSet.size("Parts") > 0)
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest number of parts: {}".format(self.partSet.size("Parts")), file=dbgFile)
- dbgFile.close()
- # ===========================================
aPartsList = []
for aPartIndex in range(self.partSet.size("Parts")):
self.session.startOperation()
aPart.activate()
self.session.finishOperation()
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest test part: {}".format(aPartIndex), file=dbgFile)
- dbgFile.close()
- # ===========================================
aPartFeature = PartSetAPI.PartSetAPI_Part(self.partSet.currentFeature(True))
# check reference data
exec(open(self.reffile, "rb").read())
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest test part finished", file=dbgFile)
- dbgFile.close()
- # ===========================================
if __name__ == "__main__":
if len(sys.argv) > 5:
TestHDF.reffile = sys.argv[5]
- # ===========================================
- dbgFile = open(os.getcwd() + "/dbgfile", 'a')
- print(" UnitTest started with parameters:", file=dbgFile)
- print(" testfile: {}".format(TestHDF.testfile), file=dbgFile)
- print(" salomePortFile: {}".format(salomePortFile), file=dbgFile)
- print(" salomeKernelDir: {}".format(salomeKernelDir), file=dbgFile)
- print(" reffile: {}".format(TestHDF.reffile), file=dbgFile)
- dbgFile.close()
- # ===========================================
aTest = unittest.TestLoader().loadTestsFromTestCase(TestHDF)
unittest.TextTestRunner(stream=errFile).run(aTest)
errFile.close()
-# test_program = unittest.main(argv=[sys.argv[0]], exit=False)
+ # close Salome GUI
proc = subprocess.Popen(salomeKernelDir + "/bin/salome/killSalome.py")
try:
os.remove(salomePortFile)
except:
print("Cannot remove file", file=f)
-
-# assert test_program.result.wasSuccessful(), "Test failed"