def testPrivateDataMembers(self): try: data = 92 u = language.DataMembers(data) k = u.hidden self.failUnless(0, "AttributeError not thrown") except AttributeError: pass # OK!
def testPublicDataMembers1(self): data = 92 u = language.DataMembers(data) self.assertEquals(u.square, data * data); self.assertEquals(type(u.e), language.El); self.assertEquals(u.m, language.EM); self.assertEquals(u.zero, 0)
def testEnums(self): self.failUnless(type(language.EM) is language.Em); self.assertEquals(type(language.EM), language.Em); d = language.DataMembers(1) d.setEm(language.EM) self.assertEquals(d.m, language.EM) d.setEm(language.Em(1)) self.assertEquals(d.m, language.Em(1))
def testSaver(self): import language import with_xparam import xparam import StringIO arg = 71 dm = language.DataMembers(arg) out = StringIO.StringIO() xparam.Saver(out).save(dm) self.assertEquals(out.getvalue().strip(), "DataMembers(%i)" % (arg * arg))
def testPublicDataMembers2(self): data = 26 u = language.DataMembers(data) u.v.v = data self.assertEquals(u.v.v, data)