Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 def test_not_existing_object(self):
     with self.assertRaises(ValueError):
         Object("wrong object type")
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 def on_setattr(self, mem, name, value):
     raise Object.setattr(mem, name, value)