def test_sqrt(self): self.assertEqual(calc.sqrt(2), 4)
import calc a=input("Enter the a value:") b=input("Enter the b value:") print "Sum of the a and b is:",calc.add(a,b) print "Difference of the a and b is:",calc.diff(a,b) print "Multiplication of the a and b is:",calc.mul(a,b) print "Divison of the a and b is:",calc.div(a,b) print "Square root of the a is:",calc.sqrt(a) print "Square root of the b is:",calc.sqrt(b) print "floordiv of the a and b is:",calc.floordiv(a,b) print "modulus of the a and b is:",calc.mod(a,b) print "Prime number verification for a:",calc.prime(a) print "Prime number verification for b:",calc.prime(b)
def test_sqrt ( self ): self.assertEqual(calc.sqrt( 4 ), 2 )
class CalcExTests ( unittest.TestCase ): def test_sqrt ( self ): self.assertEqual(calc.sqrt( 4 ), 2 )
def test_sqrt(self): """Тест на извлечение корня """ print("id: " + self.id()) self.assertEqual(calc.sqrt(4), 2)
def test_sqrt_wrong_type(): with pytest.raises(TypeError): sqrt("4")
def test_sqrt_negative_value(): with pytest.raises(ValueError): sqrt(-1)
def test_sqrt_correct_value(): assert sqrt(4) == 2