コード例 #1
0
 def testNonSlotted(self):
     c = SlottedContainer()
     c.id = "container"
     thing = Item(id='thing')
     c.add(thing)
     self.assertEquals(thing.location(),c)
     self.assert_(thing in c.contains)
     c.remove(thing)
     self.assertFalse(thing.location)
     self.assertFalse('thing' in c.contains)
コード例 #2
0
 def testMoveSlots(self):
     c = SlottedContainer()
     c.id = "container"
     c.slotNames = ['head','hand']
     thing = Item(id='thing')
     thing.fitsInSlots = ['hand','head']
     c.add(thing,'hand')
     self.assertEquals(c.slots['hand'](),thing)
     self.assertEquals(thing.location(),c)
     self.assertEquals(thing.locationSlot,'hand')
     c.add(thing,'head')
     self.assertEquals(c.slots['head'](),thing)
     self.assertEquals(thing.location(),c)
     self.assertEquals(thing.locationSlot,'head')
コード例 #3
0
 def testSlotted(self):
     c = SlottedContainer()
     c.id = "container"
     c.slotNames = ['hand']
     thing = Item(id='thing')
     thing.fitsInSlots = ['hand']
     c.add(thing,'hand')
     self.assertEquals(c.slots['hand'](),thing)
     self.assertEquals(thing.location(),c)
     self.assertEquals(thing.locationSlot,'hand')
     c.remove(thing)
     self.assertFalse(thing.location)
     self.assertFalse(thing.locationSlot)
     self.assertRaises(GameException,c.add,thing,'head')