[PyObjC-svn] r2474 - in trunk/pyobjc/pyobjc-core: Lib/PyObjCTools Lib/objc PyObjCTest
[email protected] Sun, 09 May 2010 08:26:47 -0500
| Newsgroups | gmane.comp.python.pyobjc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: ronaldoussoren
Date: Sun May 9 08:26:46 2010
New Revision: 2474
Log:
Add tests for python2 dict API, not all tests
pass at this time
Added:
trunk/pyobjc/pyobjc-core/PyObjCTest/test2_dict_interface.py (contents, props changed)
trunk/pyobjc/pyobjc-core/PyObjCTest/test2_dictviews.py (contents, props changed)
Modified:
trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py
trunk/pyobjc/pyobjc-core/Lib/objc/_convenience.py
trunk/pyobjc/pyobjc-core/PyObjCTest/test_set_interface.py
Modified: trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py (original)
+++ trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py Sun May 9 08:26:46 2010
@@ -271,11 +271,11 @@
if not hasattr(tp, "__typestr__"):
self.fail(message or "%r is not an opaque-pointer"%(tp,))
- def assertIsObject(self, value, test, message = None):
+ def assertIs(self, value, test, message = None):
if value is not test:
self.fail(message or "%r (id=%r) is not %r (id=%r) "%(value, id(value), test, id(test)))
- def assertIsNotObject(self, value, test, message = None):
+ def assertIsNot(self, value, test, message = None):
if value is test:
self.fail(message or "%r is %r"%(value, test))
@@ -706,6 +706,8 @@
failUnlessIsNotIn = _deprecate(assertIsNotIn)
failIfIsIn = _deprecate(assertIsNotIn)
assertNotIsInstance = _deprecate(assertIsNotInstance)
+ assertIsObject = _deprecate(assertIs)
+ assertIsNotObject = _deprecate(assertIsNot)
del _deprecate
Modified: trunk/pyobjc/pyobjc-core/Lib/objc/_convenience.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/objc/_convenience.py (original)
+++ trunk/pyobjc/pyobjc-core/Lib/objc/_convenience.py Sun May 9 08:26:46 2010
@@ -766,7 +766,7 @@
)
-if sys.version_info[0] == 3 or (sys.version_info[0] == 2 and sys.version_info[1] >= 7):
+if sys.version_info[0] == 3 or (sys.version_info[0] == 2 and sys.version_info[1] >= 6):
import collections
def all_contained_in(inner, outer):
@@ -980,7 +980,11 @@
elif len(args) == 1:
d = dict()
- for k , v in args[0]:
+ if isinstance(args[0], collections.Mapping):
+ items = args[0].iteritems()
+ else:
+ items = args[0]
+ for k , v in items:
d[container_wrap(k)] = container_wrap(v)
for k, v in kwds.iteritems():
@@ -1009,7 +1013,6 @@
if sys.version_info[0] == 3:
CLASS_METHODS['NSDictionary'] = (
- ('__new__', nsdict_new),
('fromkeys', classmethod(nsdict_fromkeys)),
('keys', lambda self: nsdict_keys(self)),
('values', lambda self: nsdict_values(self)),
@@ -1017,26 +1020,24 @@
)
CLASS_METHODS['NSMutableDictionary'] = (
- ('__new__', nsmutabledict_new),
('fromkeys', classmethod(nsmutabledict_fromkeys)),
)
else:
CLASS_METHODS['NSDictionary'] = (
- ('__new__', nsdict_new),
('fromkeys', classmethod(nsdict_fromkeys)),
('viewkeys', lambda self: nsdict_keys(self)),
('viewvalues', lambda self: nsdict_values(self)),
('viewitems', lambda self: nsdict_items(self)),
)
- CLASS_METHODS['NSMutableDictionary'] = (
- ('__new__', nsdict_new),
- )
+ NSDictionary.__new__ = nsdict_new
+ NSMutableDictionary.__new__ = nsmutabledict_new
- #FIXME: This shouldn't be necessary
NSMutableDictionary.dictionary()
+ #FIXME: This shouldn't be necessary
+
NSMutableArray = lookUpClass('NSMutableArray')
def nsarray_add(self, other):
result = NSMutableArray.arrayWithArray_(self)
@@ -1330,7 +1331,7 @@
for value in self:
if value in totest:
toremove.add(value)
- for value in other:
+ for value in totest:
if value not in self:
toadd.add(value)
Modified: trunk/pyobjc/pyobjc-core/PyObjCTest/test_set_interface.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/PyObjCTest/test_set_interface.py (original)
+++ trunk/pyobjc/pyobjc-core/PyObjCTest/test_set_interface.py Sun May 9 08:26:46 2010
@@ -248,8 +248,41 @@
self.b = NSMutableSet('alacazam')
-# TestVariousIteratorArgs
-# TestGraphs
+class TestVariousIteratorArgs (test.test_set.TestVariousIteratorArgs):
+ def setUp(self):
+ test.test_set.set = NSMutableSet
+
+ def tearDown(self):
+ del test.test_set.set
+
+ def test_inplace_methods(self):
+ for data in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5), 'december'):
+ for methname in ('update', 'intersection_update', 'difference_update', 'symmetric_difference_update'):
+ for g in (test.test_set.G, test.test_set.I, test.test_set.Ig, test.test_set.S, test.test_set.L, test.test_set.R):
+ #s = set('january')
+ s = NSMutableSet('january')
+ #t = s.copy()
+ t = s.mutableCopy()
+ getattr(s, methname)(list(g(data)))
+ getattr(t, methname)(g(data))
+ self.assertEqual(sorted(s), sorted(t))
+
+ self.assertRaises(TypeError, getattr(set('january'), methname), test.test_set.X(data))
+ self.assertRaises(TypeError, getattr(set('january'), methname), test.test_set.N(data))
+ self.assertRaises(ZeroDivisionError, getattr(set('january'), methname), test.test_set.E(data))
+
+
+
+
+class TestGraphs (test.test_set.TestGraphs):
+ def setUp(self):
+ test.test_set.set = NSMutableSet
+
+ def tearDown(self):
+ del test.test_set.set
+
+
+
------------------------------------------------------------------------------