1from PyObjCTools.TestSupport import * 2 3from Foundation import * 4 5try: 6 unicode 7except NameError: 8 unicode = str 9 10class TestNSFileHandle (TestCase): 11 def testConstants(self): 12 self.assertIsInstance(NSFileHandleOperationException, unicode) 13 self.assertIsInstance(NSFileHandleReadCompletionNotification, unicode) 14 self.assertIsInstance(NSFileHandleReadToEndOfFileCompletionNotification, unicode) 15 self.assertIsInstance(NSFileHandleConnectionAcceptedNotification, unicode) 16 self.assertIsInstance(NSFileHandleDataAvailableNotification, unicode) 17 self.assertIsInstance(NSFileHandleNotificationDataItem, unicode) 18 self.assertIsInstance(NSFileHandleNotificationFileHandleItem, unicode) 19 self.assertIsInstance(NSFileHandleNotificationMonitorModes, unicode) 20 21 def testMethods(self): 22 f = NSFileHandle.alloc().initWithFileDescriptor_closeOnDealloc_(0, False) 23 self.assertArgIsBOOL(f.initWithFileDescriptor_closeOnDealloc_, 1) 24 25 @min_os_level('10.6') 26 def testMethods10_6(self): 27 self.assertArgIsOut(NSFileHandle.fileHandleForReadingFromURL_error_, 1) 28 self.assertArgIsOut(NSFileHandle.fileHandleForWritingToURL_error_, 1) 29 self.assertArgIsOut(NSFileHandle.fileHandleForUpdatingURL_error_, 1) 30 31 @min_os_level('10.7') 32 def testMethods10_7(self): 33 self.assertArgIsBlock(NSFileHandle.setReadabilityHandler_, 0, b'v@') 34 self.assertArgIsBlock(NSFileHandle.setWriteabilityHandler_, 0, b'v@') 35 self.assertResultIsBlock(NSFileHandle.readabilityHandler, b'v@') 36 self.assertResultIsBlock(NSFileHandle.writeabilityHandler, b'v@') 37 38 39if __name__ == "__main__": 40 main() 41