def test_rational_numbers_are_set_to_None_if_values_are_not_valid(self): """Test if the return is none for the denominator or numerator incorrect values""" f1 = Rational(4, 0) f2 = Rational(2.1, 5) f3 = Rational(3, 6.2) f4 = Rational('a', 2) f5 = Rational(3, 'b') assert f1 is None assert f2 is None assert f3 is None assert f4 is None assert f5 is None
def test_rational_number_imul(self, r1, r2): """test __imul__ method for Rational objects""" r1 = Rational(1, 8) r1 *= r2 assert r1.__str__() == "1/32"
def test_rational_number_isub(self, r1, r2): """test __isub__ method for Rational objects""" r1 = Rational(1, 8) r1 -= r2 assert r1.__str__() == "-1/8"
def test_rational_number_iadd(self, r1, r2): """test __iadd__ method for Rational objects""" r1 = Rational(1, 8) r1 += r2 assert r1.__str__() == "3/8"
def r1(self): r1 = Rational(1, 8) return r1
def r3(self): r3 = Rational(1, 8) return r3
def r2(self): r2 = Rational(1, 4) return r2