/[escript]/trunk/dudley/test/python/fixme_run_generators.py
ViewVC logotype

Diff of /trunk/dudley/test/python/fixme_run_generators.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1044 by gross, Mon Mar 19 07:29:31 2007 UTC revision 1135 by gross, Wed May 9 01:58:32 2007 UTC
# Line 27  try: Line 27  try:
27  except KeyError:  except KeyError:
28       FINLEY_WORKDIR='.'       FINLEY_WORKDIR='.'
29    
30  FINLEY_TEST_MESH_PATH=FINLEY_TEST_DATA+"/data_meshes/"  FINLEY_TEST_MESH_PATH=os.path.join(FINLEY_TEST_DATA,"data_meshes")
31  if os.name == "nt":  FINLEY_WORKDIR_PATH=FINLEY_WORKDIR
    FINLEY_TEST_MESH_PATH = FINLEY_TEST_MESH_PATH+"win32/"  
 FINLEY_WORKDIR_PATH=FINLEY_WORKDIR+"/"  
32    
33  TEST_FILE_EXT=".test"  TEST_FILE_EXT=".test"
34  class Test_Generators(unittest.TestCase):  class Test_Generators(unittest.TestCase):
35    
36     def checker(self,dom,reference):     def checker(self,dom,reference):
37        dom_file=FINLEY_WORKDIR_PATH+TEST_FILE_EXT        dom_file=os.path.join(FINLEY_WORKDIR_PATH,TEST_FILE_EXT)
38        dom.write(dom_file)        dom.write(dom_file)
39  # Uncomment this section to dump the files for regression testing  # Uncomment this section to dump the files for regression testing
40  #      if True:  #      if True:
41  #         dom.write(FINLEY_TEST_MESH_PATH+reference)  #         dom.write(os.path.join(FINLEY_TEST_MESH_PATH,reference))
42        dom_string=open(dom_file).read().splitlines()        dom_string=open(dom_file).read().splitlines()
43        ref_string=open(FINLEY_TEST_MESH_PATH+reference).read().splitlines()        ref_string=open(os.path.join(FINLEY_TEST_MESH_PATH,reference)).read().splitlines()
44        self.failUnlessEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")        self.failUnlessEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")
45        for l in range(1,len(ref_string)):        for l in range(1,len(ref_string)):
46           self.failUnlessEqual(dom_string[l].strip(),ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),dom_string[l].strip()))           line=dom_string[l].strip()
47             if os.name == "nt":
48                  line=line.replace("e+00","e+0").replace("e-00","e-0")
49             self.failUnlessEqual(line,ref_string[l].strip(),"line %d=""%s"" in mesh file does not match line ""%s"" in reference %s" %(l,ref_string[l].strip(),line,os.path.join(FINLEY_TEST_MESH_PATH,reference)))
50    
51     def test_hex_1D_order1(self):     def test_hex_1D_order1(self):
52        file="hex_1D_order1.msh"        file="hex_1D_order1.msh"
# Line 177  class Test_GMSHReader(unittest.TestCase) Line 178  class Test_GMSHReader(unittest.TestCase)
178        ref_string=open(reference_file).read().splitlines()        ref_string=open(reference_file).read().splitlines()
179        self.failUnlessEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")        self.failUnlessEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")
180        for l in range(1,len(ref_string)):        for l in range(1,len(ref_string)):
181           self.failUnlessEqual(dom_string[l].strip(),ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),dom_string[l].strip()))           line=dom_string[l].strip()
182             if os.name == "nt":
183                  line=line.replace("e+00","e+0").replace("e-00","e-0")
184             self.failUnlessEqual(line,ref_string[l].strip(),"line %d=""%s"" in mesh file does not match line ""%s"" in reference %s" %(l,ref_string[l].strip(),line,reference_file))
185    
186     def test_Tri3(self):     def test_Tri3(self):
187         file="tri3_gmsh.msh"         file="tri3_gmsh.msh"
188         ref ="tri3.fly"         ref ="tri3.fly"
189         test = FINLEY_WORKDIR+os.sep+"tri3_test.fly"         test = os.path.join(FINLEY_WORKDIR,"tri3_test.fly")
190         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2)         dom = ReadGmsh(os.path.join(FINLEY_TEST_MESH_PATH,file),2)
191         dom.write(test)         dom.write(test)
192         self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)         self.compare(test, os.path.join(FINLEY_TEST_MESH_PATH,ref))
193    
194     def test_Tri6(self):     def test_Tri6(self):
195         file="tri6_gmsh.msh"         file="tri6_gmsh.msh"
196         ref="tri6.fly"         ref="tri6.fly"
197         test = FINLEY_WORKDIR+os.sep+"tri8_test.fly"         test = os.path.join(FINLEY_WORKDIR,"tri8_test.fly")
198         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2)         dom = ReadGmsh(os.path.join(FINLEY_TEST_MESH_PATH,file),2)
199         dom.write(test)         dom.write(test)
200         self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)         self.compare(test, os.path.join(FINLEY_TEST_MESH_PATH,ref))
201    
202     def test_Tet4(self):     def test_Tet4(self):
203         file="tet4_gmsh.msh"         file="tet4_gmsh.msh"
204         ref="tet4.fly"         ref="tet4.fly"
205         test = FINLEY_WORKDIR+os.sep+"tet4_test.fly"         test = os.path.join(FINLEY_WORKDIR,"tet4_test.fly")
206         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3)         dom = ReadGmsh(os.path.join(FINLEY_TEST_MESH_PATH,file),3)
207         dom.write(test)         dom.write(test)
208         self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)         self.compare(test, os.path.join(FINLEY_TEST_MESH_PATH,ref))
209    
210     def test_Tet(self):     def test_Tet(self):
211         file="tet10_gmsh.msh"         file="tet10_gmsh.msh"
212         ref="tet10.fly"         ref="tet10.fly"
213         test = FINLEY_WORKDIR+os.sep+"tet10_test.fly"         test = os.path.join(FINLEY_WORKDIR,"tet10_test.fly")
214         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3)         dom = ReadGmsh(os.path.join(FINLEY_TEST_MESH_PATH,file),3)
215         dom.write(test)         dom.write(test)
216         self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)         self.compare(test, os.path.join(FINLEY_TEST_MESH_PATH,ref))
217    
218  class Test_Reader(unittest.TestCase):  class Test_Reader(unittest.TestCase):
219     def test_ReadWriteTagNames(self):     def test_ReadWriteTagNames(self):
220         file="hex_2D_order2.msh"         file="hex_2D_order2.msh"
221         test = FINLEY_WORKDIR+os.sep+"test.fly"         test = os.path.join(FINLEY_WORKDIR,"test.fly")
222         dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+file,3)         dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,file),3)
223         insertTagNames(dom,A=1,B=2)         insertTagNames(dom,A=1,B=2)
224         dom.write(test)         dom.write(test)
225         dom2 = ReadMesh(test,3)         dom2 = ReadMesh(test,3)

Legend:
Removed from v.1044  
changed lines
  Added in v.1135

  ViewVC Help
Powered by ViewVC 1.1.26