Commits

Ronald Oussoren  committed a4ac761

Small test tweaks to ensure running with 2.6

  • Participants
  • Parent commits 946fc6f
  • Branches pyobjc-ancient

Comments (0)

Files changed (19)

File pyobjc-core/Lib/PyObjCTools/TestSupport.py

         if isinstance(value, types):
             self.fail(message or "%s is an instance of %r"%(value, types))
 
-    def assertIsIn(self, value, seq, message=None):
+    def assertIn(self, value, seq, message=None):
         if value not in seq:
             self.fail(message or "%r is not in %r"%(value, seq))
 
-    def assertIsNotIn(self, value, seq, message=None):
+    def assertNotIn(self, value, seq, message=None):
         if value in seq:
             self.fail(message or "%r is in %r"%(value, seq))
 
             return original_func(*args, **kwds)
         return deprecated_func
 
+    failUnlessIsIn = _deprecate(assertIn)
+    failUnlessIsNotIn = _deprecate(assertNotIn)
+    assertIsIn = _deprecate(assertIn)
+    assertIsNotIn = _deprecate(assertNotIn)
     failUnlessIsCFType = _deprecate(assertIsCFType)
     failUnlessIsOpaquePointer = _deprecate(assertIsOpaquePointer)
     failUnlessIsNone = _deprecate(assertIsNone)

File pyobjc-core/PyObjCTest/test2_dict_interface.py

 
     def test_contains(self):
         d = NSMutableDictionary({})
-        self.assertIsNotIn('a', d)
+        self.assertNotIn('a', d)
         self.assertFalse('a' in d)
         self.assertTrue('a' not in d)
         d = NSMutableDictionary({'a': 1, 'b': 2})
-        self.assertIsIn('a', d)
-        self.assertIsIn('b', d)
-        self.assertIsNotIn('c', d)
+        self.assertIn('a', d)
+        self.assertIn('b', d)
+        self.assertNotIn('c', d)
 
         self.assertRaises(TypeError, d.__contains__)
 

File pyobjc-core/PyObjCTest/test2_dictviews.py

         self.assertNotEqual(keys, set([1, "b"]))
         self.assertNotEqual(keys, set([1]))
         self.assertNotEqual(keys, 42)
-        self.assertIsIn(1, keys)
-        self.assertIsIn("a", keys)
-        self.assertIsNotIn(10, keys)
-        self.assertIsNotIn("Z", keys)
+        self.assertIn(1, keys)
+        self.assertIn("a", keys)
+        self.assertNotIn(10, keys)
+        self.assertNotIn("Z", keys)
         self.assertEqual(d.viewkeys(), d.viewkeys())
         e = NSMutableDictionary({1: 11, "a": "def"})
         self.assertEqual(d.viewkeys(), e.viewkeys())
         self.assertNotEqual(items, set([(1, 10), ("a", "def")]))
         self.assertNotEqual(items, set([(1, 10)]))
         self.assertNotEqual(items, 42)
-        self.assertIsIn((1, 10), items)
-        self.assertIsIn(("a", "ABC"), items)
-        self.assertIsNotIn((1, 11), items)
-        self.assertIsNotIn(1, items)
-        self.assertIsNotIn((), items)
-        self.assertIsNotIn((1,), items)
-        self.assertIsNotIn((1, 2, 3), items)
+        self.assertIn((1, 10), items)
+        self.assertIn(("a", "ABC"), items)
+        self.assertNotIn((1, 11), items)
+        self.assertNotIn(1, items)
+        self.assertNotIn((), items)
+        self.assertNotIn((1,), items)
+        self.assertNotIn((1, 2, 3), items)
         self.assertEqual(d.viewitems(), d.viewitems())
         e = d.mutableCopy()
         self.assertEqual(d.viewitems(), e.viewitems())

File pyobjc-core/PyObjCTest/test3_dict_interface.py

         d = self.createDictionary(a=1, b=2)
         k = d.keys()
 
-        self.assertIsIn('a', d)
-        self.assertIsIn('b', d)
-        self.assertIsIn('a', k)
-        self.assertIsIn('b', k)
+        self.assertIn('a', d)
+        self.assertIn('b', d)
+        self.assertIn('a', k)
+        self.assertIn('b', k)
 
         self.assertIsNotInstance(k, list)
 
         d = self.createDictionary(a=1, b=2)
         k = d.keys()
 
-        self.assertIsIn('a', d)
-        self.assertIsIn('b', d)
-        self.assertIsIn('a', k)
-        self.assertIsIn('b', k)
+        self.assertIn('a', d)
+        self.assertIn('b', d)
+        self.assertIn('a', k)
+        self.assertIn('b', k)
 
         self.assertIsNotInstance(k, list)
 
-        self.assertIsNotIn('c', d)
-        self.assertIsNotIn('c', k)
+        self.assertNotIn('c', d)
+        self.assertNotIn('c', k)
 
         d['c'] = 3
-        self.assertIsIn('c', d)
-        self.assertIsIn('c', k)
+        self.assertIn('c', d)
+        self.assertIn('c', k)
 
     def testValuesMutable(self):
         d = self.createDictionary()

File pyobjc-core/PyObjCTest/test3_typecheck.py

         ]
         d = {}
         objc.loadBundleFunctions(bundle, d, tab)
-        self.assertIsIn('NSHomeDirectory', d)
+        self.assertIn('NSHomeDirectory', d)
 
 
         tab = [
 
         d = {}
         objc.loadBundleVariables(bundle, d, tab)
-        self.assertIsIn('NSAppleScriptErrorMessage', d)
+        self.assertIn('NSAppleScriptErrorMessage', d)
 
 
 

File pyobjc-core/PyObjCTest/test_bundleFunctions.py

         d = {}
         objc.loadBundleFunctions(self.bundle, d, FUNCTIONS)
 
-        self.assertIsIn('NSIsFreedObject', d)
-        self.assertIsIn('NSCountFrames', d)
-        self.assertIsIn('NSHomeDirectory', d)
+        self.assertIn('NSIsFreedObject', d)
+        self.assertIn('NSCountFrames', d)
+        self.assertIn('NSHomeDirectory', d)
 
         # Don't use this API, it is unsupported and causes warnings.
         #fn = d[u'NSIsFreedObject']

File pyobjc-core/PyObjCTest/test_bundleVariables.py

                 ('NSBundleDidLoadNotification', b'@'),
             ])
 
-        self.assertIsIn(u'NSBundleDidLoadNotification', d)
-        self.assertIsIn(u'NSAppleScriptErrorMessage', d)
+        self.assertIn(u'NSBundleDidLoadNotification', d)
+        self.assertIn(u'NSAppleScriptErrorMessage', d)
 
         self.assertIsInstance(d[u'NSAppleScriptErrorMessage'], objc.pyobjc_unicode)
         self.assertIsInstance(d[u'NSBundleDidLoadNotification'], objc.pyobjc_unicode)
                 ('NSFoundationVersionNumber', objc._C_DBL),
             ])
 
-        self.assertIsIn('NSDebugEnabled', d)
-        self.assertIsIn('NSFoundationVersionNumber', d)
+        self.assertIn('NSDebugEnabled', d)
+        self.assertIn('NSFoundationVersionNumber', d)
 
         self.assertIsInstance(d['NSFoundationVersionNumber'], float)
         self.assertIsInstance(d['NSDebugEnabled'], int)

File pyobjc-core/PyObjCTest/test_ivar.py

         # Note: cannot check the exact contents of dir(), who knows
         # what NSObject defines...
         v = objc.listInstanceVariables(obj)
-        self.assertIsIn(('charValue', objc._C_CHR), v)
-        self.assertIsIn(('intValue', objc._C_INT), v)
-        self.assertIsIn(('isa', objc._C_CLASS), v)
+        self.assertIn(('charValue', objc._C_CHR), v)
+        self.assertIn(('intValue', objc._C_INT), v)
+        self.assertIn(('isa', objc._C_CLASS), v)
 
     
     def testAnonymousIvar(self):

File pyobjc-core/PyObjCTest/test_locking.py

 
         thr.join()
 
-        self.assertIsNotIn("LOCK FOUND", lst)
+        self.assertNotIn("LOCK FOUND", lst)
         for idx in range(len(lst)):
             if lst[idx].endswith(' a'):
                 self.assertTrue(lst[idx+1].endswith(' b'))
 
         thr.join()
 
-        self.assertIsNotIn("LOCK FOUND", lst)
+        self.assertNotIn("LOCK FOUND", lst)
         for idx in range(len(lst)):
             if lst[idx].endswith(' a'):
                 self.assertTrue(lst[idx+1].endswith(' b'))
 
         thr.join()
 
-        self.assertIsNotIn("LOCK FOUND", lst)
+        self.assertNotIn("LOCK FOUND", lst)
         for idx in range(len(lst)):
             if lst[idx].endswith(' a'):
                 self.assertTrue(lst[idx+1].endswith(' b'))

File pyobjc-core/PyObjCTest/test_metadata.py

     def testSuggestions(self):
         meta = OC_MetaDataTest.varargsMethodWithObjects_.__metadata__()
         self.assertIsInstance(meta, dict)
-        self.assertIsIn('suggestion', meta)
+        self.assertIn('suggestion', meta)
         self.assertEquals(meta['suggestion'], "Variadic functions/methods are not supported")
 
         meta = OC_MetaDataTest.ignoreMethod.__metadata__()
         self.assertIsInstance(meta, dict)
-        self.assertIsIn('suggestion', meta)
+        self.assertIn('suggestion', meta)
         self.assertEquals(meta['suggestion'], "please ignore me")
 
     def testPrintfFormat(self): 
         meta = OC_MetaDataTest.makeArrayWithFormat_.__metadata__()
         self.assertEquals(meta['variadic'], True)
-        self.assertIsNotIn('printf_format', meta['arguments'][0])
+        self.assertNotIn('printf_format', meta['arguments'][0])
         self.assertEquals(meta['arguments'][2]['printf_format'], True)
 
     def testVariadic(self):
 
     def testAllowNull(self):
         meta = OC_MetaDataTest.make4Tuple_.__metadata__()
-        self.assertIsNotIn('null_accepted', meta['retval'])
-        self.assertIsNotIn( 'null_accepted', meta['arguments'][0])
+        self.assertNotIn('null_accepted', meta['retval'])
+        self.assertNotIn( 'null_accepted', meta['arguments'][0])
 
         meta = OC_MetaDataTest.make4Tuple_.__metadata__()
         self.assertEquals(meta['arguments'][2]['null_accepted'], False)

File pyobjc-core/PyObjCTest/test_metadata_function.py

 class TestExists (TestCase):
     def testFunctionsExists(self):
         for item in _FunctionTable:
-            self.assertIsIn(item[0], globals())
+            self.assertIn(item[0], globals())
 
 class TestArrayDefault (TestCase):
     # TODO: what is the default anyway?

File pyobjc-core/PyObjCTest/test_methodaccess.py

 
         d = dir(o.pyobjc_instanceMethods)
         self.assertGreaterThan(len(d), 10)
-        self.assertIsIn("init", d)
+        self.assertIn("init", d)
 
         d = dir(NSObject.pyobjc_classMethods)
         self.assertGreaterThan(len(d), 10)
-        self.assertIsIn("alloc", d)
+        self.assertIn("alloc", d)
 
     def testDict(self):
         o = NSObject.new()
 
         d = o.pyobjc_instanceMethods.__dict__.keys()
         self.assertGreaterThan(len(d), 10)
-        self.assertIsIn("init", d)
+        self.assertIn("init", d)
 
         d = NSObject.pyobjc_classMethods.__dict__.keys()
         self.assertGreaterThan(len(d), 10)
-        self.assertIsIn("alloc", d)
+        self.assertIn("alloc", d)
 
         #d = o.pyobjc_classMethods.__dict__.keys()
         #self.assertGreaterThan(len(d), 10)
-        #self.assertIsIn("alloc", d)
+        #self.assertIn("alloc", d)
 
     def testAttributes(self):
         o = NSObject.new()

File pyobjc-core/PyObjCTest/test_methods.py

         OC_TestClass1.clsReset()
         self.assertEquals(len(OC_TestClass1.idClsFunc()), 0)
         self.assertEquals(type(OC_TestClass1.idClsFunc()).__name__, 'NSHost')
-        self.assertIsIn(str(OC_TestClass1.idClsFunc()), ('{}', '{\n}'))
+        self.assertIn(str(OC_TestClass1.idClsFunc()), ('{}', '{\n}'))
         self.assertEquals(OC_TestClass1.idClsFunc(), None)
 
     # testCls* ends here
         obj.reset()
         self.assertEquals(len(obj.idFunc()), 0)
         self.assertEquals(type(obj.idFunc()).__name__, 'NSHost')
-        self.assertIsIn(str(obj.idFunc()), ('{}', '{\n}'))
+        self.assertIn(str(obj.idFunc()), ('{}', '{\n}'))
         self.assertEquals(obj.idFunc(), None)
 
     def testStruct1(self):

File pyobjc-core/PyObjCTest/test_number_proxy.py

         #   printf("%llu\n", lv);
         # 
 
-        self.assertIsIn(
+        self.assertIn(
                 OC_TestNumber.numberAsUnsignedLongLong_(v),
                     (18446744073709551489, 18446744073709551488))
 

File pyobjc-core/PyObjCTest/test_objc.py

         NSException = objc.lookUpClass('NSException')
         NSMutableArray = objc.lookUpClass('NSMutableArray')
 
-        self.assertIsIn(NSObject, objc.getClassList())
-        self.assertIsIn(NSException, objc.getClassList())
-        self.assertIsIn(NSMutableArray, objc.getClassList())
+        self.assertIn(NSObject, objc.getClassList())
+        self.assertIn(NSException, objc.getClassList())
+        self.assertIn(NSMutableArray, objc.getClassList())
 
 class TestMethodInvocation(TestCase):
     def setUp(self):
 
 class TestClassDict(TestCase):
     def testDict(self):
-        self.assertIsIn("attributesAtIndex_longestEffectiveRange_inRange_", NSAttributedString.__dict__)
+        self.assertIn("attributesAtIndex_longestEffectiveRange_inRange_", NSAttributedString.__dict__)
 
 class TestPickle(TestCase):
     # We don't support pickling at the moment, make sure we enforce that.

File pyobjc-core/PyObjCTest/test_protected.py

     def testProtectedNotInDir(self):
 
         d = dir(PyObjCTest_Protected)
-        self.assertIsIn('publicMethod', d)
-        self.assertIsNotIn('_protectedMethod', d)
+        self.assertIn('publicMethod', d)
+        self.assertNotIn('_protectedMethod', d)
 
     def testProtectedCallable(self):
         o = PyObjCTest_Protected.new()

File pyobjc-core/PyObjCTest/test_set_proxy.py

         self.assertEquals(OC_TestSet.anyObjectOfSet_(s), None)
 
         s = self.setClass([1,2,3,4])
-        self.assertIsIn(OC_TestSet.anyObjectOfSet_(s), s)
+        self.assertIn(OC_TestSet.anyObjectOfSet_(s), s)
 
     def testContainsObject_(self):
         s = self.setClass([1,2,3])

File pyobjc-core/PyObjCTest/test_subclass.py

         self.assertEquals(aList, [])
         del o
         self.assertEquals(len(aList), 2)
-        self.assertIsIn('dealloc', aList)
-        self.assertIsIn('__del__', aList)
+        self.assertIn('dealloc', aList)
+        self.assertIn('__del__', aList)
 
         class SubClassWithDealloc(ClassWithDealloc):
             def dealloc(self):
         self.assertEquals(aList, [])
         del o
         self.assertEquals(len(aList), 3)
-        self.assertIsIn('dealloc.dealloc', aList)
-        self.assertIsIn('dealloc', aList)
-        self.assertIsIn('__del__', aList)
+        self.assertIn('dealloc.dealloc', aList)
+        self.assertIn('dealloc', aList)
+        self.assertIn('__del__', aList)
 
         class ClassWithDeallocAndDel(NSObject):
             def init(self):
         self.assertEquals(aList, [])
         del o
         self.assertEquals(len(aList), 3)
-        self.assertIsIn('mydel', aList)
-        self.assertIsIn('dealloc', aList)
-        self.assertIsIn('__del__', aList)
+        self.assertIn('mydel', aList)
+        self.assertIn('dealloc', aList)
+        self.assertIn('__del__', aList)
 
     def testMethodNames(self):
 

File pyobjc-core/setup.py

             if rootdir in sys.path:
                 sys.path.remove(rootdir)
 
+        ei_cmd = self.get_finalized_command('egg_info')
+        egg_name = ei_cmd.egg_name.replace('-', '_')
+
+        to_remove = []
+        for dirname in sys.path:
+            bn = os.path.basename(dirname)
+            if bn.startswith(egg_name + "-"):
+                to_remove.append(dirname)
+
+        for dirname in to_remove:
+            log.info("removing installed %r from sys.path before testing"%(dirname,))
+            sys.path.remove(dirname)
+
         from PyObjCTest.loader import makeTestSuite
         import unittest
+
+        #import pprint; pprint.pprint(sys.path)
        
         unittest.main(None, None, [unittest.__file__]+self.test_args)
 
 ## on i386 systems when a method returns a struct that isn't returned
 ## in registers. 
 if '-O0' in get_config_var('CFLAGS'):
+    print "Change -O0 to -O1"
     CFLAGS.append('-O1')
 
 OBJC_LDFLAGS = frameworks('CoreFoundation', 'Foundation', 'Carbon')