~pythonregexp2.7/python/issue2636-01

« back to all changes in this revision

Viewing changes to Lib/test/test_macos.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-09 14:37:21 UTC
  • mfrom: (39022.1.14 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080609143721-bj0g1mwta28038da
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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()