import unittest

from heal import Heal


class HealTests(unittest.TestCase):
    def test_str(self):
        heal_amount = 5.111
        heal = Heal(heal_amount=heal_amount)
        expected_str = f'{heal_amount:.2f}'

        self.assertEqual(str(heal), expected_str)

    def test_add(self):
        """ __add__ takes a numeric type (int/float) """
        heal_amount = 5
        heal = Heal(heal_amount=heal_amount)

        add_amount = 10
        expected_amount = heal_amount + add_amount

        self.assertEqual(heal + add_amount, expected_amount)

    def test_radd(self):
        heal_amount = 5
        heal = Heal(heal_amount=heal_amount)

        add_amount = 10
        expected_amount = heal_amount + add_amount

        add_amount += heal
        self.assertEqual(add_amount, expected_amount)

    def test_iadd(self):
        heal_amount = 5
        heal = Heal(heal_amount=heal_amount)
        add_amount = 10

        expected_heal = Heal(heal_amount=heal_amount + add_amount)

        heal += add_amount
        self.assertEqual(heal, expected_heal)

    def test_sub(self):
        heal_amount = 5
        heal = Heal(heal_amount=heal_amount)
        sub_amount = 3

        expected_amount = 2

        self.assertEqual(heal - sub_amount, expected_amount)


if __name__ == '__main__':
    unittest.main()

import unittest

from heal import Heal


class HealTests(unittest.TestCase):
    def test_str(self):
        heal_amount = 5.111
        heal = Heal(heal_amount=heal_amount)
        expected_str = f'{heal_amount:.2f}'

        self.assertEqual(str(heal), expected_str)

    def test_add(self):
        """ __add__ takes a numeric type (int/float) """
        heal_amount = 5
        heal = Heal(heal_amount=heal_amount)

        add_amount = 10
        expected_amount = heal_amount + add_amount

        self.assertEqual(heal + add_amount, expected_amount)

    def test_radd(self):
        heal_amount = 5
        heal = Heal(heal_amount=heal_amount)

        add_amount = 10
        expected_amount = heal_amount + add_amount

        add_amount += heal
        self.assertEqual(add_amount, expected_amount)

    def test_iadd(self):
        heal_amount = 5
        heal = Heal(heal_amount=heal_amount)
        add_amount = 10

        expected_heal = Heal(heal_amount=heal_amount + add_amount)

        heal += add_amount
        self.assertEqual(heal, expected_heal)

    def test_sub(self):
        heal_amount = 5
        heal = Heal(heal_amount=heal_amount)
        sub_amount = 3

        expected_amount = 2

        self.assertEqual(heal - sub_amount, expected_amount)

    def test_isub(self):
        heal_amount = 5
        heal = Heal(heal_amount=heal_amount)
        sub_amount = 3

        expected_heal = Heal(heal_amount=heal_amount-sub_amount)
        heal -= sub_amount

        self.assertEqual(heal, expected_heal)


if __name__ == '__main__':
    unittest.main()

Test for Heal __isub__