/[escript]/trunk/escriptcore/test/python/test_util_base.py
ViewVC logotype

Diff of /trunk/escriptcore/test/python/test_util_base.py

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

revision 5418 by caltinay, Tue Jul 15 09:50:20 2014 UTC revision 5419 by jfenwick, Wed Jan 14 09:14:05 2015 UTC
# Line 56  class Test_util_base(unittest.TestCase): Line 56  class Test_util_base(unittest.TestCase):
56  #=========================================================  #=========================================================
57  #  File writer  #  File writer
58  #=========================================================  #=========================================================
59       def setup(self):
60            self.workdir=ESCRIPT_WORKDIR
61    
62     def __checkContent(self,fn,ref_cont):     def __checkContent(self,fn,ref_cont):
63          cont=open(fn,'r').readlines()          cont=open(fn,'r').readlines()
64          self.assertTrue(len(cont)==len(ref_cont),"wrong number of records")          self.assertTrue(len(cont)==len(ref_cont),"wrong number of records")
65          for i in range(len(cont)):          for i in range(len(cont)):
66             self.assertTrue(cont[i].strip()==ref_cont[i],"wrong records %s"%i)             self.assertTrue(cont[i].strip()==ref_cont[i],"wrong records %s"%i)
67     def test_FileWriter_W(self):     def test_FileWriter_W(self):
68          fn=os.path.join(ESCRIPT_WORKDIR, "filewriter_w.txt")          fn=os.path.join(self.workdir, "filewriter_w.txt")
69          self.assertRaises(IOError,FileWriter,fn="",append=False)          self.assertRaises(IOError,FileWriter,fn="",append=False)
70          f=FileWriter(fn,append=False)          f=FileWriter(fn,append=False)
71          self.assertTrue(f.name==fn, "wrong file name.")          self.assertTrue(f.name==fn, "wrong file name.")
# Line 80  class Test_util_base(unittest.TestCase): Line 83  class Test_util_base(unittest.TestCase):
83          if getMPIRankWorld()==0: os.unlink(fn)          if getMPIRankWorld()==0: os.unlink(fn)
84    
85     def test_FileWriter_A(self):     def test_FileWriter_A(self):
86          fn=os.path.join(ESCRIPT_WORKDIR, "filewriter_a.txt")          fn=os.path.join(self.workdir, "filewriter_a.txt")
87          if getMPIRankWorld()==0: open(fn,'w').write("line1"+os.linesep)          if getMPIRankWorld()==0: open(fn,'w').write("line1"+os.linesep)
88          self.assertRaises(IOError,FileWriter,fn="",append=True)          self.assertRaises(IOError,FileWriter,fn="",append=True)
89          f=FileWriter(fn,append=True)          f=FileWriter(fn,append=True)
# Line 99  class Test_util_base(unittest.TestCase): Line 102  class Test_util_base(unittest.TestCase):
102          if getMPIRankWorld()==0: os.unlink(fn)          if getMPIRankWorld()==0: os.unlink(fn)
103    
104     def test_FileWriter_A_loc(self):     def test_FileWriter_A_loc(self):
105          fn=os.path.join(ESCRIPT_WORKDIR, "filewriter_a_loc.txt")          fn=os.path.join(self.workdir, "filewriter_a_loc.txt")
106          if getMPIRankWorld()>0:          if getMPIRankWorld()>0:
107              fn2=fn+".%s"%getMPIRankWorld()              fn2=fn+".%s"%getMPIRankWorld()
108          else:          else:
# Line 121  class Test_util_base(unittest.TestCase): Line 124  class Test_util_base(unittest.TestCase):
124          os.unlink(fn2)          os.unlink(fn2)
125    
126     def test_FileWriter_W_loc(self):     def test_FileWriter_W_loc(self):
127          fn=os.path.join(ESCRIPT_WORKDIR, "filewriter_w_loc.txt")          fn=os.path.join(self.workdir, "filewriter_w_loc.txt")
128          if getMPIRankWorld()>0:          if getMPIRankWorld()>0:
129              fn2=fn+".%s"%getMPIRankWorld()              fn2=fn+".%s"%getMPIRankWorld()
130          else:          else:

Legend:
Removed from v.5418  
changed lines
  Added in v.5419

  ViewVC Help
Powered by ViewVC 1.1.26