Ronald Oussoren avatar Ronald Oussoren committed 72e23dc

Minor test tweaks

Comments (0)

Files changed (7)

pyobjc-framework-Cocoa/PyObjCTest/test_cfbundle.py

 
         v = CFBundleGetLocalInfoDictionary(bundle)
         if v is not None:
-            self.failUnlessIsInstance(v, CFDictionaryRef)
+            self.assertIsInstance(v, CFDictionaryRef)
         type, creator = CFBundleGetPackageInfo(bundle, None, None)
         self.assertIsInstance(type, (int, long))
         self.assertIsInstance(creator, (int, long))

pyobjc-framework-Cocoa/PyObjCTest/test_cfrunloop.py

         observer = CFRunLoopObserverCreate(None, kCFRunLoopEntry|kCFRunLoopExit,
                 True, 4, callback, data)
         self.assertIsInstance(observer, CFRunLoopObserverRef)
-        self.failUnless (CFRunLoopContainsObserver(rl, observer, kCFRunLoopDefaultMode) is False)
+        self.assertIs(CFRunLoopContainsObserver(rl, observer, kCFRunLoopDefaultMode), False)
         CFRunLoopAddObserver(rl, observer, kCFRunLoopDefaultMode)
-        self.failUnless (CFRunLoopContainsObserver(rl, observer, kCFRunLoopDefaultMode) is True)
+        self.assertIs(CFRunLoopContainsObserver(rl, observer, kCFRunLoopDefaultMode), True)
 
         # Use dummy stream to ensure that the runloop actually performs work
         strval = b'hello world'
             self.assertIsIn(item[1], (kCFRunLoopEntry, kCFRunLoopExit))
             self.assertIs(item[2], data)
         CFRunLoopRemoveObserver(rl, observer, kCFRunLoopDefaultMode)
-        self.failUnless (CFRunLoopContainsObserver(rl, observer, kCFRunLoopDefaultMode) is False)
+        self.assertIs(CFRunLoopContainsObserver(rl, observer, kCFRunLoopDefaultMode), False)
 
 
     def testTimer(self):

pyobjc-framework-Cocoa/PyObjCTest/test_cfusernotification.py

         self.assertIsInstance(flags, (int, long))
         v = CFUserNotificationGetResponseDictionary(ref)
         if v is not None:
-            self.failUnlessIsInstance(v, CFDictionaryRef)
+            self.assertIsInstance(v, CFDictionaryRef)
         error = CFUserNotificationUpdate(ref, 2.0, 0, infoDict)
         self.assertEqual(error , 0)
         error = CFUserNotificationCancel(ref)
         
         v = CFUserNotificationGetResponseValue(ref, kCFUserNotificationTextFieldValuesKey, 0)
         if v is not None:
-            self.failUnlessIsInstance(v, unicode)
+            self.assertIsInstance(v, unicode)
     def testAlert(self):
         err, flags = CFUserNotificationDisplayAlert(0.1, 0, None, None, None, "Header", "Message", "Cancel", None, None, None)
         self.assertEqual(err , 0)

pyobjc-framework-Cocoa/PyObjCTest/test_nscoder.py

 from Foundation import *
 from PyObjCTest.testhelper import PyObjC_TestClass4
 
+try:
+    memoryview
+except NameError:
+    memoryview = None
+
 class TestNSCoderUsage(TestCase):
     def testUsage(self):
         class CoderClass1 (NSObject):

pyobjc-framework-Cocoa/PyObjCTest/test_nsdata.py

 if sys.version_info[0] == 3:
     buffer = memoryview
 
+try:
+    memoryview
+except NameError:
+    memoryview = None
+
 class TestNSData(TestCase):
     def testMethods(self):
         self.assertResultIsBOOL(NSData.writeToFile_atomically_)
         b, err = NSData.alloc().initWithContentsOfFile_options_error_(
                 "/etc/hosts", 0, None)
         self.assertIsInstance(b, NSData)
-        self.assertIsObject(err, None)
+        self.assertIs(err, None)
         b2, err = NSData.alloc().initWithContentsOfFile_options_error_(
                 "/etc/hosts.nosuchfile", 0, None)
-        self.assertIsObject(b2, None)
+        self.assertIs(b2, None)
         self.assertIsInstance(err, NSError)
         url = NSURL.fileURLWithPath_isDirectory_('/etc/hosts', False)
         b, err = NSData.alloc().initWithContentsOfURL_options_error_(
                 url, 0, None)
         self.assertIsInstance(b, NSData)
-        self.assertIsObject(err, None)
+        self.assertIs(err, None)
         url = NSURL.fileURLWithPath_isDirectory_('/etc/hosts.nosuchfile', False)
         b2, err = NSData.alloc().initWithContentsOfURL_options_error_(
                 url, 0, None)
-        self.assertIsObject(b2, None)
+        self.assertIs(b2, None)
         self.assertIsInstance(err, NSError)
 class MyData (NSData):
     def dataWithBytes_length_(self, bytes, length):

pyobjc-framework-Cocoa/PyObjCTest/test_nsview.py

         method = ObjCTestNSView_KnowPageRange.rectForPage_
 
 
-        self.failUnlessResultHasType(method, NSRect.__typestr__)
+        self.assertResultHasType(method, NSRect.__typestr__)
         #self.assertEqual(objc.splitSignature(method.signature), objc.splitSignature(NSRect.__typestr__+b"@:" + objc._C_NSInteger))
 
 

pyobjc-framework-Cocoa/pyobjc_setup.py

             sys.path.remove(dirname)
 
         # Actually run the tests
+        if sys.version_info[0] == 2:
+            sys.path.insert(0, rootdir)
         import PyObjCTest
         import unittest
         from pkg_resources import EntryPoint
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.