def on_getattr(self, mem, name): if name == u"to": return self.load(mem.pointer, False) if name == u"str" and self.size == 1: s = rffi.charp2str(rffi.cast(rffi.CCHARP, mem.pointer)) return String(s.decode('utf-8')) raise Object.getattr(mem, name)
def test_creature(self): object_type = "creature" creature = Object(object_type) self.assertEqual(creature.type, object_type) self.assertEqual(creature.color, POSSIBLE_OBJECTS[object_type]["color"]) self.assertEqual(creature.moved_in_current_round, False)
def test_not_existing_object(self): with self.assertRaises(ValueError): Object("wrong object type")
def on_setattr(self, mem, name, value): if name == u"to": return self.store(mem.pool, mem.pointer, value) raise Object.setattr(mem, name, value)
def on_setattr(self, mem, name, value): raise Object.setattr(mem, name, value)