-# Copyright (C) 2006-2013 CEA/DEN, EDF R&D
+# Copyright (C) 2006-2021 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
def test1_edit(self):
p = self.r.createProc("pr")
- print p.typeMap
+ print(p.typeMap)
t=p.getTypeCode("double")
- print t.kind()
+ print(t.kind())
t=p.typeMap["double"]
td=p.createType("double","double")
ti=p.createType("int","int")
tc1=p.createInterfaceTc("","Obj",[])
- print tc1.name(),tc1.id()
+ print(tc1.name(),tc1.id())
tc2=p.createInterfaceTc("","Obj2",[tc1])
- print tc2.name(),tc2.id()
+ print(tc2.name(),tc2.id())
tc3=p.createSequenceTc("","seqdbl",td)
- print tc3.name(),tc3.id(),tc3.contentType()
+ print(tc3.name(),tc3.id(),tc3.contentType())
tc4=p.createSequenceTc("","seqObj2",tc2)
tc5=p.createSequenceTc("","seqint",ti)
- print tc4.name(),tc4.id()
- print tc4.isA(tc1),0
- print tc2.isA(tc1),1
- print tc1.isA(tc2),0
- print td.isA(ti),0
- print td.isAdaptable(ti),1
- print ti.isAdaptable(td),0
- print tc5.isAdaptable(tc3),0
- print tc3.isAdaptable(tc5),1
+ print(tc4.name(),tc4.id())
+ print(tc4.isA(tc1),0)
+ print(tc2.isA(tc1),1)
+ print(tc1.isA(tc2),0)
+ print(td.isA(ti),0)
+ print(td.isAdaptable(ti),1)
+ print(ti.isAdaptable(td),0)
+ print(tc5.isAdaptable(tc3),0)
+ print(tc3.isAdaptable(tc5),1)
n=self.r.createScriptNode("","node1")
- n.setScript("print 'coucou1'")
+ n.setScript("print('coucou1')")
n.edAddInputPort("p1",ti)
n.edAddOutputPort("p1",ti)
p.edAddChild(n)
retex=None
try:
inport.edInitXML("<value><intt>5</int></value>")
- except ValueError, ex:
- print "Value Error: ", ex
+ except ValueError as ex:
+ print("Value Error: ", ex)
retex=ex
- except pilot.Exception,ex:
- print "YACS exception:",ex.what()
+ except pilot.Exception as ex:
+ print("YACS exception:",ex.what())
retex=ex.what()
- self.assert_(retex is not None, "exception not raised, or wrong type")
+ self.assertTrue(retex is not None, "exception not raised, or wrong type")
inport.edInitXML("<value><int>5</int></value>")
# --- create script node node2
n2=self.r.createScriptNode("","node2")
- n2.setScript("print 'coucou2'")
+ n2.setScript("print('coucou2')")
n2.edAddInputPort("p1",ti)
p.edAddChild(n2)
# --- end of node
n=self.r.createFuncNode("","node3")
n.setScript("""
def f():
- print 'coucou3'
+ print('coucou3')
""")
n.setFname("f")
p.edAddChild(n)
b=self.r.createBloc("b1")
p.edAddChild(b)
- n=self.r.createScriptNode("","b1.node2")
- n.setScript("print 'coucou2'")
+ n=self.r.createScriptNode("","b1@node2")
+ n.setScript("print('coucou2')")
b.edAddChild(n)
# --- end bloc
ip=lo.edGetNbOfTimesInputPort()
ip.edInitInt(3)
- n=self.r.createScriptNode("","l1.node2")
- n.setScript("print 'coucou2'")
+ n=self.r.createScriptNode("","l1@node2")
+ n.setScript("print('coucou2')")
lo.edSetNode(n)
# --- end loop
# --- create a while loop with one node
wh=self.r.createWhileLoop("w1")
p.edAddChild(wh)
- n=self.r.createFuncNode("","w1.node3")
+ n=self.r.createFuncNode("","w1@node3")
n.setScript("""
def f():
- print 'coucou3'
+ print('coucou3')
return 0
""")
n.setFname("f")
# --- create a switch
sw=self.r.createSwitch("sw1")
p.edAddChild(sw)
- n=self.r.createFuncNode("","sw1.node3")
+ n=self.r.createFuncNode("","sw1@node3")
n.setScript("""
def f():
- print 'case1'
+ print('case1')
return 0
""")
n.setFname("f")
n.edAddOutputPort("p1",ti)
sw.edSetNode(1,n)
- n=self.r.createFuncNode("","sw1.node4")
+ n=self.r.createFuncNode("","sw1@node4")
n.setScript("""
def f():
- print 'default'
+ print('default')
return 0
""")
n.setFname("f")
try:
self.e.RunW(p,0)
- except pilot.Exception,ex:
- print ex.what()
+ except pilot.Exception as ex:
+ print(ex.what())
self.fail(ex)
#self.e.displayDot(p)
-import os
-U = os.getenv('USER')
-f=open("/tmp/" + U + "/UnitTestsResult", 'a')
-f.write(" --- TEST src/yacsloader: testEdit.py\n")
-suite = unittest.makeSuite(TestEdit)
-result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
-f.close()
-sys.exit(not result.wasSuccessful())
+if __name__ == '__main__':
+ import os
+ U = os.getenv('USER')
+ with open("/tmp/" + U + "/UnitTestsResult", 'a') as f:
+ f.write(" --- TEST src/yacsloader: testEdit.py\n")
+ suite = unittest.makeSuite(TestEdit)
+ result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
+ sys.exit(not result.wasSuccessful())