1""" 2Minimal tests for sequence proxies 3 4NOTE: this file is very, very incomplete and just tests copying at the moment. 5""" 6import sys 7from PyObjCTools.TestSupport import * 8from PyObjCTest.fnd import NSDictionary, NSMutableDictionary, NSPredicate, NSObject, NSNull 9from PyObjCTest.pythonset import OC_TestSet 10import objc 11 12OC_PythonDictionary = objc.lookUpClass("OC_PythonDictionary") 13 14 15 16 17 18class TestMutableSequence (TestCase): 19 mapClass = dict 20 21 def testCopy(self): 22 s = self.mapClass() 23 o = OC_TestSet.set_copyWithZone_(s, None) 24 self.assertEquals(s, o) 25 self.assert_(s is not o) 26 27 s = self.mapClass({1:2, 'a':'c'}) 28 o = OC_TestSet.set_copyWithZone_(s, None) 29 self.assertEquals(s, o) 30 self.assert_(s is not o) 31 32 def testProxyClass(self): 33 # Ensure that the right class is used to proxy sets 34 self.assert_(OC_TestSet.classOf_(self.mapClass()) is OC_PythonDictionary) 35 36 def testMutableCopy(self): 37 38 s = self.mapClass({1:2, 'a':'c'}) 39 o = OC_TestSet.set_mutableCopyWithZone_(s, None) 40 self.assertEquals(dict(s), o) 41 self.assert_(s is not o) 42 self.assert_(isinstance(o, dict)) 43 44 s = self.mapClass() 45 o = OC_TestSet.set_mutableCopyWithZone_(s, None) 46 self.assertEquals(dict(s), o) 47 self.assert_(s is not o) 48 self.assert_(isinstance(o, dict)) 49 50 51 52 53if __name__ == "__main__": 54 main() 55