def test_unit_setter(): soldier = Unit('Soldier', 100, 20) assert soldier.hp == 100 soldier.hp = 50 assert soldier.hp == 50 soldier.hp += 50 assert soldier.hp == 100 soldier.hp -= 90 assert soldier.hp == 10 with pytest.raises(ValueError): soldier.hp = -100 assert soldier.hp == 10 with pytest.raises(ValueError): soldier.hp -= 100 assert soldier.hp == 10
def test_unit_setters(): soldier = Unit('SoLdIeR', 100, 100, 20) assert soldier.hp == 100 soldier.hp = 50 assert soldier.hp == 50 soldier.hp += 50 assert soldier.hp == 100 soldier.maxHP -= 90 assert soldier.maxHP == 10 with pytest.raises(ValueError): soldier.hp = -100 with pytest.raises(ValueError): soldier.hp -= 100 soldier.dmg = 50 assert soldier.dmg == 50 soldier.name = 'Ivan' assert soldier.name == 'Ivan'
def test_add_hit_points(actual, expected): unit = Unit('Soldier', 100, 20) unit.hp = 50 unit.add_hit_points(actual) assert unit.hp == expected