def dont_testOpenAppendInObjC(self):
        # We can't reliably detect append mode, don't bother testing for it.
        o = OC_TestFilePointer.new()
        fp = o.openFile_withMode_('/tmp/pyobjc.filepointer.txt', 'a')
        self.assertIsInstance(fp, file)
        self.assertEqual(fp.mode, 'a')

        o = OC_TestFilePointer.new()
        fp = o.openFile_withMode_('/tmp/pyobjc.filepointer.txt', 'a+')
        self.assertIsInstance(fp, file)
        self.assertEqual(fp.mode, 'a+')
예제 #2
0
    def testOpenInPython(self):
        fp = objc.FILE("/etc/passwd", "r")
        o = OC_TestFilePointer.new()
        line = o.readline_(fp)
        fp.close()

        self.assertEqual(line, gFirstPasswdLine.decode("utf-8"))
    def testOpenInPython(self):
        fp = open('/etc/passwd', 'r')
        o = OC_TestFilePointer.new()
        line = o.readline_(fp)
        fp.close()

        self.assertEqual(line, gFirstPasswdLine)
예제 #4
0
    def testOpenReadingInObjC(self):
        o = OC_TestFilePointer.new()
        fp = o.openFile_withMode_(b"/etc/passwd", b"r")
        self.assertIsInstance(fp, objc.FILE)

        line = fp.readline()
        fp.close()

        self.assertEqual(line, gFirstPasswdLine)
    def testOpenReadingInObjC(self):
        o = OC_TestFilePointer.new()
        fp = o.openFile_withMode_('/etc/passwd', 'r')
        self.assertIsInstance(fp, file)
        self.assertEqual(fp.mode, 'r')

        line = fp.readline()
        fp.close()

        self.assertEqual(line, gFirstPasswdLine)
예제 #6
0
    def testOpenWritingInObjC(self):
        o = OC_TestFilePointer.new()
        fp = o.openFile_withMode_(b"/tmp/pyobjc.filepointer.txt", b"w")
        self.assertIsInstance(fp, objc.FILE)

        fp.write(b"foobar\n")
        fp.close()

        fp = open("/tmp/pyobjc.filepointer.txt")
        data = fp.read()
        self.assertEqual(data, "foobar\n")
        fp.close()
    def testOpenWritingInObjC(self):
        o = OC_TestFilePointer.new()
        fp = o.openFile_withMode_('/tmp/pyobjc.filepointer.txt', 'w')
        self.assertIsInstance(fp, file)
        self.assertEqual(fp.mode, 'w')

        fp.write('foobar\n')
        fp.flush()
        fp.close()

        fp = open('/tmp/pyobjc.filepointer.txt')
        data = fp.read()
        self.assertEqual(data, 'foobar\n')
        fp.close()
예제 #8
0
    def testOpenWritingInObjC(self):
        o = OC_TestFilePointer.new()
        fp = o.openFile_withMode_('/tmp/pyobjc.filepointer.txt', 'w')
        self.assert_(isinstance(fp, file))
        self.assertEquals(fp.mode, 'w')

        fp.write('foobar\n')
        fp.flush() # XXX: this isn't quite correct?
        fp.close()

        fp = open('/tmp/pyobjc.filepointer.txt')
        data = fp.read()
        self.assertEquals(data, 'foobar\n')
        fp.close()
예제 #9
0
    def testOpenWritingInObjC(self):
        o = OC_TestFilePointer.new()
        fp = o.openFile_withMode_("/tmp/pyobjc.filepointer.txt", "w")
        self.assertIsInstance(fp, file)
        self.assertEqual(fp.mode, "w")

        fp.write("foobar\n")
        fp.flush()  # XXX: this isn't quite correct?
        fp.close()

        fp = open("/tmp/pyobjc.filepointer.txt")
        data = fp.read()
        self.assertEqual(data, "foobar\n")
        fp.close()
예제 #10
0
 def testOpenReadWriteInObjC(self):
     o = OC_TestFilePointer.new()
     fp = o.openFile_withMode_('/tmp/pyobjc.filepointer.txt', 'w+')
     self.assertIsInstance(fp, file)
     self.assertEqual(fp.mode, 'w+')
예제 #11
0
 def testOpenReadWriteInObjC(self):
     o = OC_TestFilePointer.new()
     fp = o.openFile_withMode_(b"/tmp/pyobjc.filepointer.txt", b"w+")
     self.assertIsInstance(fp, objc.FILE)
     fp.close()