1   
 2   
 3  from translate.storage import txt 
 4  from translate.storage import test_monolingual 
 5  from translate.misc import wStringIO 
 6   
 9   
10   
11 -class TestTxtFile(test_monolingual.TestMonolingualStore): 
 12      StoreClass = txt.TxtFile 
14          """helper that parses txt source without requiring files""" 
15          dummyfile = wStringIO.StringIO(txtsource) 
16          txtfile = self.StoreClass(dummyfile) 
17          return txtfile 
 18   
20          """helper that converts txt source to txtfile object and back""" 
21          return str(self.txtparse(txtsource)) 
 22   
24          """checks that a simple txt block is parsed correctly""" 
25          txtsource = 'bananas for sale' 
26          txtfile = self.txtparse(txtsource) 
27          assert len(txtfile.units) == 1 
28          assert txtfile.units[0].source == txtsource 
29          assert self.txtregen(txtsource) == txtsource 
 30   
32          """ check that multiple blocks are parsed correctly""" 
33          txtsource = '''One\nOne\n\nTwo\n---\n\nThree''' 
34          txtfile = self.txtparse(txtsource) 
35          assert len(txtfile.units) == 3 
36          print txtsource 
37          print str(txtfile) 
38          print "*%s*" % txtfile.units[0] 
39          assert str(txtfile) == txtsource 
40          assert self.txtregen(txtsource) == txtsource 
  41