Пример #1
0
 def test_fractions_add(self):
     '''Testing __add__ method'''
     assert self.frac1 + self.frac2 == Fraction(1, 1)
Пример #2
0
 def test_fractions_sub(self):
     '''Testing __sub__ method'''
     assert self.frac1 - self.frac2 == Fraction(-1, 3)
Пример #3
0
 def test_init_simplification(self):
     '''Testing init with gcd'''
     assert self.frac2 == Fraction(2, 3)
Пример #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'
Пример #5
0
 def setup_class(cls):
     '''Setting up'''
     cls.frac1 = Fraction(1, 3)
     cls.frac2 = Fraction(4, 6)
     cls.frac3 = Fraction(6, 4)
Пример #6
0
 def test_init(self):
     '''Testing init'''
     assert self.frac1 == Fraction(1, 3)
Пример #7
0
 def test_fractions_mult(self):
     """Testing __mult__ method"""
     assert self.frac1 * self.frac2 == Fraction(2, 9)
Пример #8
0
 def setup_class(self):
     """Setting up"""
     self.frac1 = Fraction(1, 3)
     self.frac2 = Fraction(4, 6)
     self.frac3 = Fraction(6, 4)
Пример #9
0
 def test_fractions_add(self):
     """Testing __add__ method"""
     assert self.frac1 + self.frac2 == Fraction(1, 1)
Пример #10
0
 def test_fractions_sub(self):
     """Testing __sub__ method"""
     assert self.frac1 - self.frac2 == Fraction(-1, 3)
Пример #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"
Пример #12
0
 def test_init_simplification(self):
     """Testing init with gcd"""
     assert self.frac2 == Fraction(2, 3)
Пример #13
0
 def test_init(self):
     """Testing init"""
     assert self.frac1 == Fraction(1, 3)
Пример #14
0
 def test_fractions_mult(self):
     '''Testing __mult__ method'''
     assert self.frac1 * self.frac2 == Fraction(2, 9)
Пример #15
0
 def test_fractions_truediv(self):
     """Testing __truediv__ method"""
     assert self.frac1 / self.frac2 == Fraction(1, 2)
Пример #16
0
 def test_fractions_truediv(self):
     '''Testing __truediv__ method'''
     assert self.frac1 / self.frac2 == Fraction(1, 2)
Пример #17
0
 def setup_class(self):
     '''Setting up'''
     self.frac1 = Fraction(1, 3)
     self.frac2 = Fraction(4, 6)
     self.frac3 = Fraction(6, 4)