示例#1
0
    def test_backpack(self):
        bp = Backpack()

        bp.add_item(Equipment('test1', 10))
        eq2 = bp.add_item(Equipment('test2', 10))

        self.assertEqual(20, bp.get_weight(), 'Get weight is not equal')
        bp.pop_item(eq2)
        self.assertEqual(10, bp.get_weight(), 'Get weight is not equal')
示例#2
0
    def test_backpack(self):
        bp = Backpack()
        self.assertIsNotNone(bp)

        bp.add_item(Equipment('test1', 10))
        bp.add_item(Equipment('test2', 10))

        self.assertEqual(20, bp.get_weight(), 'Get weight is not equal')
        self.assertEqual(-1, bp.add_item(Equipment('test3', 100)))
示例#3
0
 def test_equipment_str(self):
     equip = Equipment('equipment', 10)
     self.assertEqual(str(equip), 'equipment , Wgt: 10')
示例#4
0
 def test_Equip_fail_none(self):
     with self.assertRaises(AssertionError):
         Equipment('equip', None)
示例#5
0
 def test_Equip_fail_type(self):
     with self.assertRaises(AssertionError):
         Equipment('equip', '1')
示例#6
0
文件: Weapon.py 项目: gpkort/dndai
 def __init__(self, name: str, weight: int=0, damage=None, is_armed: bool=False):
     Equipment.__init__(self, name, weight)
     self.damage = damage
     self.is_armed = is_armed
示例#7
0
 def test_equipment(self):
     equip = Equipment('test', 20)
     self.assertIsNotNone(equip)