def test_add(self): self.assertEqual(calc.add(10.39, 20.39),30.78) self.assertEqual(calc.add(-10, 5),-5) self.assertEqual(calc.add("yes", 10),"Error") self.assertEqual(calc.add(10, "ten"),"Error") self.assertEqual(calc.add("10", 10), 20)
def test_add(self): # first word must be 'test' self.assertEqual(calc.add(10, 5), 15) self.assertEqual(calc.add(-1, 1), 0) self.assertEqual(calc.add(-1, -1), -2)
def test_add(): assert calc.add(1, 2) == 3
def test_add_2arg(self): # Make sure 3 + 4 = 7 self.assertEqual(add(3, 4), 7, 'adding three and four')
def test_add_string_2(self): self.assertEqual('Invalid input', calc.add('1', 1))
def test_add(self): self.assertEqual(calc.add(1, 1), 2)
# import entire module '''import calc calc.add(45,34,23) calc.div(10,5) calc.mul(9,7)''' #import req. functions from calc import add from calc import mul add(45, 56) mul(9, 8) #imported functions can be renamed from calc import div as division division(20, 10) #import all the functions from calc import * sub(7, 2)
def test_add_negative(self): self.assertEqual(0, calc.add(1, -1))
def test_sum2(self): self.assertEqual(calc.add(5, -4), 1)
def test_addition(self): """testing addition""" self.assertEqual(add(1, 2), 3)
def test_sum1(self): self.assertEqual(calc.add(5, 4), 9)
def test_add(self): self.assertEqual(calc.add(10,6),16) self.assertEqual(calc.add(-5,6),1) self.assertEqual(calc.add(10.8,-0.8),10) self.assertEqual(calc.add(-20,"a"),"DTNS")
def testAdd(self): self.assertEqual(4, add(2, 2)) self.assertEqual(2, add(0, 2))
def test_add(self): print 'Now test add' self.assertEqual(calc.add(self.num1, self.num2), 15)
from calc import add a = 9 b = 7 c = add(a, b) print(c)
a=9 print(a) import calc print(calc.add(99,66))
def test_add_wrong_value(): assert add(1, 3) != 5
def test_add_associative(self): self.assertEqual(calc.add(2, calc.add(3, 4)), calc.add(calc.add(2, 3), 4))
def test_add_wrong_type(): with pytest.raises(TypeError): add(1, "3")
def test_add(self): self.assertEqual(3, calc.add(1, 2))
def test_add_value(): assert add(1, 3) == 4
def test_add(self): result = calc.add(10, 5) self.assertEquals(result, 15)
def test_sub(self): self.assertEqual(calc.add(1, 5), 7) self.assertEqual(calc.add(3, 5), 4)
def test_add(self): self.assertEqual(add(-1, 1), 0) self.assertEqual(add(-1, -1), -2) self.assertEqual(add(10, 5), 15)
def test_add(self): # result = calc.add(10, 5) self.assertEqual(calc.add(10, 5), 15) self.assertEqual(calc.add(-1, 1), 0) self.assertEqual(calc.add(-1, -1), -2)
def test_add_number(self): self.assertEqual(add(3, 8), 11)
def test_add(): assert add(1, 2) == 3
def test_add(self): result = calc.add(10,5) self.assertEqual(result, 15)
def test_add(self): self.assertEqual(calc.add(1, 2), 3)
from calc import add, multi print(add(1, 2, 3)) print(multi(2, 3))
def test_add(self, value): result = calc.add(value, value) self.assertEqual(result, 15)
def test_A(self): result = calc.add(5, 6) self.assertEqual(result, 11)
def test_add(self): self.assertEqual(calc.add(8, 9), 17) self.assertEqual(calc.add(-1, 1), 0) self.assertEqual(calc.add(-1, -1), -2)
def test_add_float(self): self.assertEqual(2.6, calc.add(1.5, 1.1))
def fun2(): add() print("from fun2")
def test_add_commutative(self): self.assertEqual(calc.add(2, 1), calc.add(1, 2))
def fun1(): add() add() print("from fun1")
def test_add_string(self): self.assertEqual('Invalid input', calc.add(1, '1'))
def test_add(self): self.assertEqual(calc.add(20, 5), 25) self.assertEqual(calc.add(-1, 1), 0) self.assertEqual(calc.add(-1, -1), -2)
def test_add2(self): self.assertEqual(0.3, calc.add(0.1, 0.2))
import math print(id(math)) print(type(math)) print(math) print(math.pi) print("-" * 50) print(dir(math)) print(math.pow(2, 2), type(math.pow(2, 2))) print(math.ceil(9.001)) print(math.floor(9.999)) print("-" * 50) # import calc from calc import add print(add(12, 4)) # print(calc.div(12,4))
import calc print(calc.add(1, 2)) # https://qiita.com/Tocyuki/items/fb99d9bdb71875843357
def test_addition(self): result = calc.add(2, 3) self.assertEqual(5, result)
def test_add(self): self.assertEqual(calc.add(10, 5), 15) self.assertEqual(calc.add(-1, 1), 0) self.assertEqual(calc.add(-1, -1), -2)
def test_add(num1, num2, output): assert calc.add(num1, num2) == output
def test_calc_add(self): result = calc.add(self.a, self.b) self.assertEqual(result, self.a + self.b)
from calc import( add ,sub ) print sub(10, 2) - add(3, 3)