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.assertEqual(s, o)
25        self.assertIsNot(s, o)
26
27        s = self.mapClass({1:2, 'a':'c'})
28        o = OC_TestSet.set_copyWithZone_(s, None)
29        self.assertEqual(s, o)
30        self.assertIsNot(s, o)
31
32    def testProxyClass(self):
33        # Ensure that the right class is used to proxy sets
34        self.assertIs(OC_TestSet.classOf_(self.mapClass()), 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.assertEqual(dict(s), o)
41        self.assertIsNot(s, o)
42        self.assertIsInstance(o, dict)
43
44        s = self.mapClass()
45        o = OC_TestSet.set_mutableCopyWithZone_(s, None)
46        self.assertEqual(dict(s), o)
47        self.assertIsNot(s, o)
48        self.assertIsInstance(o, dict)
49
50
51
52
53if __name__ == "__main__":
54    main()
55