示例#1
0
def testBagCreationAndAddingItems():
    potion = ItemFactory(ItemList.Potion)
    b = Bag(100, [potion])
    assert b.getCurrentWeight() == potion.getWeight()
    newPotion = ItemFactory(ItemList.Potion)
    b.addItem(newPotion)
    assert b.getCurrentWeight() == potion.getWeight() + newPotion.getWeight()
示例#2
0
def testBagCreationAndFailureInAddingItems():
    potion = ItemFactory(ItemList.Potion)
    b = Bag(16,[potion])
    assert b.getCurrentWeight() == potion.getWeight()
    newPotion = ItemFactory(ItemList.Potion)
    assert b.addItem(newPotion)== False 
    assert b.getCurrentWeight() == potion.getWeight()
    assert b.getAllItems()== [potion]