home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 July / maximum-cd-2011-07.iso / DiscContents / LibO_3.3.2_Win_x86_install_multi.exe / libreoffice1.cab / test_macos.py < prev    next >
Encoding:
Python Source  |  2011-03-15  |  1004 b   |  44 lines

  1. import unittest
  2. import MacOS
  3. import Carbon.File
  4. from test import test_support
  5. import os
  6.  
  7. TESTFN2 = test_support.TESTFN + '2'
  8.  
  9. class TestMacOS(unittest.TestCase):
  10.  
  11.     def testOpenRF(self):
  12.         try:
  13.             fp = open(test_support.TESTFN, 'w')
  14.             fp.write('hello world\n')
  15.             fp.close()
  16.  
  17.             rfp = MacOS.openrf(test_support.TESTFN, '*wb')
  18.             rfp.write('goodbye world\n')
  19.             rfp.close()
  20.  
  21.  
  22.             fp = open(test_support.TESTFN, 'r')
  23.             data = fp.read()
  24.             fp.close()
  25.             self.assertEquals(data, 'hello world\n')
  26.  
  27.             rfp = MacOS.openrf(test_support.TESTFN, '*rb')
  28.             data = rfp.read(100)
  29.             data2 = rfp.read(100)
  30.             rfp.close()
  31.             self.assertEquals(data, 'goodbye world\n')
  32.             self.assertEquals(data2, '')
  33.  
  34.  
  35.         finally:
  36.             os.unlink(test_support.TESTFN)
  37.  
  38. def test_main():
  39.     test_support.run_unittest(TestMacOS)
  40.  
  41.  
  42. if __name__ == '__main__':
  43.     test_main()
  44.