def __setattr__(self,name,val):
     if name is 'special':
         return
     elif name in self.__class__.__dict__:
         fp = self.__class__.__dict__[name]
         fp.__set__(self,val)
     else:
         helpers.gen_setter(self.__dict__,name,val)
 def __setattr__(self, name, val):
     if name == 'special':
         return
     elif name in self.__class__.__dict__:
         fp = self.__class__.__dict__[name]
         fp.__set__(self, val)
     else:
         helpers.gen_setter(self.__dict__, name, val)
    def test_gen_setter(self):
        kkdict = {}
        kkdict['A'] = helpers.ComplexProperty(['B', 'C'])
        kkdict['B'] = 19
        kkdict['C'] = 1000

        helpers.gen_setter(kkdict, 'B', 0)
        self.assertEqual(kkdict['B'], 0)
        helpers.gen_setter(kkdict, 'C', 10)
        self.assertEqual(kkdict['C'], 10)

        self.assertRaises(KeyError, helpers.gen_setter, kkdict, 'A', 100)
        self.assertEqual(kkdict['B'], 0)

        helpers.gen_setter(kkdict, 'A', [1, 10])
        self.assertEqual(kkdict['B'], 1)
        self.assertEqual(kkdict['C'], 10)

        helpers.gen_setter(kkdict, 'A', (2, 20))
        self.assertEqual(kkdict['B'], 2)
        self.assertEqual(kkdict['C'], 20)
    def test_gen_setter(self):
        kkdict = {}
        kkdict['A']=helpers.ComplexProperty(['B','C'])
        kkdict['B']=19
        kkdict['C']=1000


        helpers.gen_setter(kkdict,'B',0)
        self.assertEqual(kkdict['B'],0)
        helpers.gen_setter(kkdict,'C',10)
        self.assertEqual(kkdict['C'],10)

        self.assertRaises(KeyError,helpers.gen_setter,kkdict,'A',100)
        self.assertEqual(kkdict['B'],0)

        helpers.gen_setter(kkdict,'A',[1,10])
        self.assertEqual(kkdict['B'],1)
        self.assertEqual(kkdict['C'],10)

        helpers.gen_setter(kkdict,'A',(2,20))
        self.assertEqual(kkdict['B'],2)
        self.assertEqual(kkdict['C'],20)
Exemple #5
0
    def test_gen_setter(self):
        kkdict = {};
        kkdict['A']=helpers.ComplexProperty(['B','C']);
        kkdict['B']=19;
        kkdict['C']=1000;
   

        helpers.gen_setter(kkdict,'B',0)
        self.assertEqual(kkdict['B'],0);
        helpers.gen_setter(kkdict,'C',10)
        self.assertEqual(kkdict['C'],10);

        self.assertRaises(KeyError,helpers.gen_setter,kkdict,'A',100)
        self.assertEqual(kkdict['B'],0);

        helpers.gen_setter(kkdict,'A',[1,10])
        self.assertEqual(kkdict['B'],1);
        self.assertEqual(kkdict['C'],10);
 def __setattr__(self,name,val):
     if  name in self.__exmeth:
         object.__setattr__(self,name,val)
     else:
         helpers.gen_setter(self.__dict__,name,val)
 def __setattr__(self, name, val):
     if name in self.__exmeth:
         object.__setattr__(self, name, val)
     else:
         helpers.gen_setter(self.__dict__, name, val)