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')
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)))
def test_equipment_str(self): equip = Equipment('equipment', 10) self.assertEqual(str(equip), 'equipment , Wgt: 10')
def test_Equip_fail_none(self): with self.assertRaises(AssertionError): Equipment('equip', None)
def test_Equip_fail_type(self): with self.assertRaises(AssertionError): Equipment('equip', '1')
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
def test_equipment(self): equip = Equipment('test', 20) self.assertIsNotNone(equip)