def test_meth_param(self): meth = addrxlat.Method(addrxlat.NOMETH, param=(0, 1, 2, 3)) self.assertGreaterEqual(len(meth.param), 4) self.assertEqual(meth.kind, addrxlat.NOMETH) self.assertEqual(meth.target_as, addrxlat.NOADDR) for i in xrange(4): self.assertEqual(meth.param[i], i) for i in xrange(4, len(meth.param)): self.assertEqual(meth.param[i], 0) for i in xrange(4): meth.param[i] += 1 self.assertEqual(meth.kind, addrxlat.NOMETH) self.assertEqual(meth.target_as, addrxlat.NOADDR) for i in xrange(4): self.assertEqual(meth.param[i], i + 1) for i in xrange(4, len(meth.param)): self.assertEqual(meth.param[i], 0) with self.assertRaises(OverflowError): meth.param[0] = 999 with self.assertRaises(OverflowError): meth.param[0] = -1
def test_meth_target_as(self): meth = addrxlat.Method(addrxlat.NOMETH, addrxlat.MACHPHYSADDR) self.assertEqual(meth.kind, addrxlat.NOMETH) self.assertEqual(meth.target_as, addrxlat.MACHPHYSADDR) for i in xrange(len(meth.param)): self.assertEqual(meth.param[i], 0)
def test_meth_readonly_kind(self): meth = addrxlat.Method(addrxlat.NOMETH) with self.assertRaises(AttributeError): meth.kind = addrxlat.LINEAR