def test__namesOfWritableDoubleAttributes(self): """check Attributes._namesOfDoubleAttributes() """ a = Attributes() self.assertEqual(0, len(a._namesOfDoubleAttributes())) a._registerDoubleAttribute('bar', lambda obj: 13) self.assertEqual(13, a._getDoubleAttr('bar')) self.assertEqual(13, a.bar) self.assertEqual(1, len(a._namesOfDoubleAttributes())) self.assertEqual(0, len(a._namesOfWritableDoubleAttributes())) pdfc = PDFCalculator() self.failUnless('extendedrmin' in pdfc._namesOfDoubleAttributes()) self.failUnless('extendedrmax' in pdfc._namesOfDoubleAttributes()) self.failIf('extendedrmin' in pdfc._namesOfWritableDoubleAttributes()) self.failIf('extendedrmax' in pdfc._namesOfWritableDoubleAttributes()) return
def test___setattr__(self): """check Attributes.__setattr__() """ # normal attribute a = Attributes() a.x = 45 self.assertTrue("x" in a.__dict__) self.assertFalse("x" in a._namesOfDoubleAttributes()) self.assertRaises(AttributeError, a._getDoubleAttr, "x") self.assertRaises(AttributeError, a._setDoubleAttr, "x", 13) del a.x a._registerDoubleAttribute("x") self.assertTrue("x" in a._namesOfDoubleAttributes()) a.x = 27 self.assertEqual(27, a._getDoubleAttr("x")) return
def test__namesOfWritableDoubleAttributes(self): """check Attributes._namesOfDoubleAttributes() """ a = Attributes() self.assertEqual(0, len(a._namesOfDoubleAttributes())) a._registerDoubleAttribute('bar', lambda obj: 13) self.assertEqual(13, a._getDoubleAttr('bar')) self.assertEqual(13, a.bar) self.assertEqual(1, len(a._namesOfDoubleAttributes())) self.assertEqual(0, len(a._namesOfWritableDoubleAttributes())) pdfc = PDFCalculator() self.failUnless('extendedrmin' in pdfc._namesOfDoubleAttributes()) self.failUnless('extendedrmax' in pdfc._namesOfDoubleAttributes()) self.failIf('extendedrmin' in pdfc._namesOfWritableDoubleAttributes()) self.failIf('extendedrmax' in pdfc._namesOfWritableDoubleAttributes()) return