Ejemplo n.º 1
0
 def test_fractions_add(self):
     '''Testing __add__ method'''
     assert self.frac1 + self.frac2 == Fraction(1, 1)
Ejemplo n.º 2
0
 def test_fractions_sub(self):
     '''Testing __sub__ method'''
     assert self.frac1 - self.frac2 == Fraction(-1, 3)
Ejemplo n.º 3
0
 def test_init_simplification(self):
     '''Testing init with gcd'''
     assert self.frac2 == Fraction(2, 3)
Ejemplo n.º 4
0
 def test_init_denom_error_2(self):
     '''Testing TypeError'''
     with pytest.raises(TypeError) as excinfo:
         Fraction(1, '2')
     exception_msg = excinfo.value.args[0]
     assert exception_msg == 'Numerator and denominator must be integers'
Ejemplo n.º 5
0
 def setup_class(cls):
     '''Setting up'''
     cls.frac1 = Fraction(1, 3)
     cls.frac2 = Fraction(4, 6)
     cls.frac3 = Fraction(6, 4)
Ejemplo n.º 6
0
 def test_init(self):
     '''Testing init'''
     assert self.frac1 == Fraction(1, 3)
Ejemplo n.º 7
0
 def test_fractions_mult(self):
     """Testing __mult__ method"""
     assert self.frac1 * self.frac2 == Fraction(2, 9)
Ejemplo n.º 8
0
 def setup_class(self):
     """Setting up"""
     self.frac1 = Fraction(1, 3)
     self.frac2 = Fraction(4, 6)
     self.frac3 = Fraction(6, 4)
Ejemplo n.º 9
0
 def test_fractions_add(self):
     """Testing __add__ method"""
     assert self.frac1 + self.frac2 == Fraction(1, 1)
Ejemplo n.º 10
0
 def test_fractions_sub(self):
     """Testing __sub__ method"""
     assert self.frac1 - self.frac2 == Fraction(-1, 3)
Ejemplo n.º 11
0
 def test_init_denom_error(self):
     """Testing TypeError"""
     with pytest.raises(TypeError) as excinfo:
         Fraction(1, 2.5)
     exception_msg = excinfo.value.args[0]
     assert exception_msg == "Numerator and denominator must be integers"
Ejemplo n.º 12
0
 def test_init_simplification(self):
     """Testing init with gcd"""
     assert self.frac2 == Fraction(2, 3)
Ejemplo n.º 13
0
 def test_init(self):
     """Testing init"""
     assert self.frac1 == Fraction(1, 3)
Ejemplo n.º 14
0
 def test_fractions_mult(self):
     '''Testing __mult__ method'''
     assert self.frac1 * self.frac2 == Fraction(2, 9)
Ejemplo n.º 15
0
 def test_fractions_truediv(self):
     """Testing __truediv__ method"""
     assert self.frac1 / self.frac2 == Fraction(1, 2)
Ejemplo n.º 16
0
 def test_fractions_truediv(self):
     '''Testing __truediv__ method'''
     assert self.frac1 / self.frac2 == Fraction(1, 2)
Ejemplo n.º 17
0
 def setup_class(self):
     '''Setting up'''
     self.frac1 = Fraction(1, 3)
     self.frac2 = Fraction(4, 6)
     self.frac3 = Fraction(6, 4)