Пример #1
0
 def testMultiple(self):
     c = Container()
     c.id = "container"
     m1 = Character(id='mob1')
     m1.name = "mob1"
     m2 = Character(id='mob2')
     m2.name = "mob2"
     c.add(m1)
     c.add(m2)
     self.assert_(m1 in c.contains)
     self.assertEquals(c.get(id='mob1'),m1)
     self.assertEquals(c.get(id='mob2'),m2)
     self.assertEquals(c.get(attribute='character'),[m1])
     c.remove(m1)
     self.assert_(m2 in c.contains)
     self.assertEquals(c.get(id='mob2'),m2)
     self.assertEquals(c.get(attribute='character'),[m2])
     c.remove(m2)
     self.assertFalse(m2 in c.contains)
     self.assertRaises(GameException,c.get,attribute='xcvc')
     self.assertRaises(GameException,c.get,attribute='mob')
Пример #2
0
 def testSingle(self):
     c = Container()
     c.id = "container"
     m = Character(id='mob')
     m.name = "mob"
     c.add(m)
     self.assertEquals(c.id,"container")
     self.assertEquals(m.id,"mob")
     self.assert_( m in c.contains)
     self.assertEquals(c.get(id='mob'),m)
     self.assertEquals(c.get(attribute='mob'),[m])
     self.assert_(m.location)
     c.remove(m)
     self.assertFalse('mob' in c.contains)
     self.assertFalse(m.location)
     pass