/[escript]/trunk/escript/test/python/test_objects.py
ViewVC logotype

Diff of /trunk/escript/test/python/test_objects.py

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

revision 3791 by caltinay, Fri Jan 27 01:43:47 2012 UTC revision 3792 by caltinay, Wed Feb 1 06:16:25 2012 UTC
# Line 199  class Test_saveCSV(unittest.TestCase): Line 199  class Test_saveCSV(unittest.TestCase):
199      self.assertTrue(os.path.exists(fname), "test file not created")      self.assertTrue(os.path.exists(fname), "test file not created")
200      f=open(fname,'r')      f=open(fname,'r')
201      line=f.readline()      line=f.readline()
202      self.assertTrue(line=="C_0, C_1, D\n")    #This tests both separator strings      self.assertEquals(line,"C_0, C_1, D\n")    #This tests both separator strings
203      #Now we find out how many rows it has      #Now we find out how many rows it has
204      linecount=0      linecount=0
205      while line != '':      while line != '':
206          linecount+=1          linecount+=1
207          line=f.readline()          line=f.readline()
208      self.assertTrue(linecount==self.linecount1*2)      self.assertEquals(linecount,self.linecount1*2)
209      f.close()      f.close()
210      #Now to other output      #Now to other output
211      T2=Tensor(7,X.getFunctionSpace())      T2=Tensor(7,X.getFunctionSpace())
# Line 214  class Test_saveCSV(unittest.TestCase): Line 214  class Test_saveCSV(unittest.TestCase):
214      saveDataCSV(fname,A=T2,B=T3,C=T4)      saveDataCSV(fname,A=T2,B=T3,C=T4)
215      f=open(fname,'r')      f=open(fname,'r')
216      line=f.readline()      line=f.readline()
217      self.assertTrue(line=='A_0_0, A_1_0, A_0_1, A_1_1, B_0_0_0, B_0_0_1, B_1_0_0, B_1_0_1, B_0_1_0, B_0_1_1, B_1_1_0, B_1_1_1, C_0_0_0_0, C_0_0_0_1, C_0_0_1_0, C_0_0_1_1, C_1_0_0_0, C_1_0_0_1, C_1_0_1_0, C_1_0_1_1, C_0_1_0_0, C_0_1_0_1, C_0_1_1_0, C_0_1_1_1, C_1_1_0_0, C_1_1_0_1, C_1_1_1_0, C_1_1_1_1\n')      self.assertEquals(line, 'A_0_0, A_1_0, A_0_1, A_1_1, B_0_0_0, B_0_0_1, B_1_0_0, B_1_0_1, B_0_1_0, B_0_1_1, B_1_1_0, B_1_1_1, C_0_0_0_0, C_0_0_0_1, C_0_0_1_0, C_0_0_1_1, C_1_0_0_0, C_1_0_0_1, C_1_0_1_0, C_1_0_1_1, C_0_1_0_0, C_0_1_0_1, C_0_1_1_0, C_0_1_1_1, C_1_1_0_0, C_1_1_0_1, C_1_1_1_0, C_1_1_1_1\n')
218      line=f.readline()      line=f.readline()
219      line_expected=[7.]*4+[8.]*8+[9.]*16      line_expected=[7.]*4+[8.]*8+[9.]*16
220      line_got=[float(elt) for elt in line.split(',')]      line_got=[float(elt) for elt in line.split(',')]
221      self.assertTrue(line_got==line_expected)      self.assertEquals(line_got,line_expected)
222      linecount=1      linecount=1
223      while line != '':      while line != '':
224          linecount+=1          linecount+=1
225          line=f.readline()          line=f.readline()
226      self.assertTrue(linecount==self.linecount1)      self.assertEquals(linecount, self.linecount1)
227      f.close()        f.close()  
228      #Now to test separators and mask      #Now to test separators and mask
229      saveDataCSV(fname, sep="|",csep="/", U=X, V=X0, mask=X0)      saveDataCSV(fname, sep="|",csep="/", U=X, V=X0, mask=X0)
230      f=open(fname,'r')      f=open(fname,'r')
231      line=f.readline()      line=f.readline()
232      self.assertTrue(line=='U/0|U/1|V\n')      self.assertEquals(line, 'U/0|U/1|V\n')
233      line=f.readline()      line=f.readline()
234      line_got=[float(elt) for elt in line.split('|')]      line_got=[float(elt) for elt in line.split('|')]
235      self.assertTrue(self.line_expected==line_got)      self.assertEquals(len(self.line_expected),len(line_got))
236        for i in range(len(self.line_expected)):
237            self.assertAlmostEquals(self.line_expected[i],line_got[i])
238      linecount=1      linecount=1
239      while line!='':      while line!='':
240          linecount+=1          linecount+=1
241          line=f.readline()          line=f.readline()
242      self.assertTrue(linecount==self.linecount2)      self.assertEquals(linecount,self.linecount2)
243            
244            
245  class Test_Domain(unittest.TestCase):  class Test_Domain(unittest.TestCase):
# Line 1573  class Test_Dump(unittest.TestCase): Line 1575  class Test_Dump(unittest.TestCase):
1575            d.setTaggedValue(100,self.arg4*4)            d.setTaggedValue(100,self.arg4*4)
1576            self._diffDataObjects(d,filemame)            self._diffDataObjects(d,filemame)
1577    
    def test_canTag_Failures(self):  
     d=Data(self.arg0,Solution(self.domain))  
     self.assertRaises(RuntimeError,d.setTaggedValue,1,self.arg0*2)  
     d=Data(self.arg0,ReducedSolution(self.domain))  
     self.assertRaises(RuntimeError,d.setTaggedValue,1,self.arg0*2)  
       
1578  class Test_Lazy(unittest.TestCase):  class Test_Lazy(unittest.TestCase):
1579    def makeLazyObj(self):    def makeLazyObj(self):
1580      d=delay(Data(1,self.mainfs,True))      d=delay(Data(1,self.mainfs,True))

Legend:
Removed from v.3791  
changed lines
  Added in v.3792

  ViewVC Help
Powered by ViewVC 1.1.26