8 from InterfaceTK import appli
9 #from Editeur import appli
10 from Accas import AsException
12 def add_param(j,pos,nom,valeur):
13 co=j.addentite("PARAMETRE",pos)
18 def add_mcsimp(obj,nom,valeur):
19 mcs=obj.get_child(nom,restreint='oui')
21 pos=obj.get_index_child(nom)
22 mcs=obj.addentite(nom,pos)
23 mcs.set_valeur(mcs.eval_val(valeur))
26 def cdiff(text1,text2):
27 return " ".join(difflib.context_diff(text1.splitlines(1),text2.splitlines(1)))
31 class TestCase(unittest.TestCase):
36 CONTEXT.unset_current_step()
39 """ Test de commentarisation/decommentarisation de commandes dans fichier az.comm"""
40 app=appli.STANDALONE(version=version)
41 file=os.path.join(prefs.INSTALLDIR,"Tests/testelem/az.comm")
42 j=app.openJDC(file=file)
43 assert j.isvalid(),j.report()
44 # on commente la commande LIRE_MAILLAGE
46 if co.nom == "LIRE_MAILLAGE" and co.sd.nom == "MAIL":break
47 cco=co.get_objet_commentarise(format=app.format_fichier.get())
48 # on decommente la commande LIRE_MAILLAGE
49 commande,nom = cco.uncomment()
50 # on reaffecte l'objet MAIL
52 if co.nom in ("AFFE_MODELE","AFFE_MATERIAU") :
53 add_mcsimp(co,"MAILLAGE",'MAIL')
55 text1=app.get_text_JDC(j,'python')
59 assert text1 == text2 , cdiff(text1,text2)
62 """ Test de commentarisation/decommentarisation de macro commande dans fichier az.comm"""
63 app=appli.STANDALONE(version=version)
64 file=os.path.join(prefs.INSTALLDIR,"Tests/testelem/az.comm")
65 j=app.openJDC(file=file)
66 assert j.isvalid(),j.report()
67 # on commente la commande MACRO_MATR_ASSE
69 if co.nom == "MACRO_MATR_ASSE" :break
70 cco=co.get_objet_commentarise(format=app.format_fichier.get())
71 # on decommente la commande MACRO_MATR_ASSE
72 commande,nom = cco.uncomment()
73 assert j.isvalid(),j.report()
76 """ Test de commentarisation/decommentarisation de commandes dans fichier az.comm"""
77 app=appli.STANDALONE(version=version)
84 assert j.isvalid(),j.report()
85 # on commente la commande LIRE_MAILLAGE
87 cco=co.get_objet_commentarise(format=app.format_fichier.get())
88 co=j.addentite("LIRE_MAILLAGE",2)
89 test,mess=co.nomme_sd("MA")
90 # on decommente la commande LIRE_MAILLAGE
91 commande,nom = cco.uncomment()
92 expected="""DEBUT CR validation : TEXT
93 Etape : LIRE_MAILLAGE ligne : ...
94 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
95 ! Concept retourné non défini !
96 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
97 Fin Etape : LIRE_MAILLAGE
98 FIN CR validation :TEXT
101 assert compare.check(expected,msg),cdiff(expected,msg)
104 """ Test de commentarisation/decommentarisation de commandes dans fichier az.comm"""
105 app=appli.STANDALONE(version=version)
109 AFFE_MODELE(MAILLAGE=MA)
113 # on commente la commande LIRE_MAILLAGE
115 cco=co.get_objet_commentarise(format=app.format_fichier.get())
116 # on commente la commande AFFE_MODELE
118 cco2=co.get_objet_commentarise(format=app.format_fichier.get())
119 # on decommente la commande AFFE_MODELE
120 commande,nom = cco2.uncomment()
121 assert commande["MAILLAGE"] == None
124 """ Test de commentarisation/decommentarisation de commandes dans fichier az.comm"""
125 app=appli.STANDALONE(version=version)
129 AFFE_MODELE(MAILLAGE=MA)
133 # on commente la commande AFFE_MODELE
135 cco2=co.get_objet_commentarise(format=app.format_fichier.get())
136 # on commente la commande LIRE_MAILLAGE
138 cco=co.get_objet_commentarise(format=app.format_fichier.get())
139 # on decommente la commande AFFE_MODELE
140 self.assertRaises(AsException, cco2.uncomment, )