def test_add(self): # For this test case, I will have two asserts # if one fails, then all the test case fails. self.assertEqual(hello.add(3,5),8) # This second assert will fail, # because I'm saying that the resukt will be 3 when the result is 15 # if we change the value to 15, then it will pass self.assertEqual(hello.add(10,5),3)
def f(): """ calls hello """ s = hello.add(7, 2) logging.debug("logging sum from caller.py:" + s) print("printing sum from caller.py:" + s)
def f(): ''' calls hello ''' s=hello.add(7,2) logging.debug('logging sum from caller.py:' + s) print 'printing sum from caller.py:', s
def test_add(): assert 2 == add(1, 1)
import hello a = hello.add(30, 40) # add(100,200) #不加模块名无法识别 print(a) from hello import * a = add(100, 200) #无需模块名,可以直接引用里面的函数/类 print(a) b = MyNum() b.print123()
def test_add(): assert add(4, 4) == 8
def test_add(self): self.assertEqual(add(3, 4), 7)
def test_add2(self): self.assertEqual(30, hello.add(10, 20))
def test_add(self): self.assertEqual(hello.add(2, 4), 6)
def test_add_strings(): result = hello.add('hello ', 'world') assert result == 'hello world' assert type(result) is str assert 'hello' in result
import hello print("hi") print(hello.add(3))
from hello import add print(add(1, 1))
def test_add(): assert add(10, 15) == 25
#!/usr/bin/env python3 import hello print(hello.add(1, 2))
def test_add(): assert add(1, 2) == 3
def test_hello_add(): assert add(1, 2) == 3
def test_add(): a = 1 b = 2 c = 3 d = hello.add(c, a) assert d == -1
def test_add(): assert hello.add(3, 8) == 11 assert hello.add(6) == 8
def test_add(): assert add(1, 3) == 4 assert add(2, 3) == 5
def test_add(self): self.assertEqual(5, hello.add(2, 3))
import hello hello.add(7,8)
def test_add(): assert hello.add(1,2) == 3
def test_add(): assert 5 + 5 == hello.add(5, 5)
from hello import add assert add(0, 0) == 0 assert add(12, 12) == 24 assert add(-12, 12) == 0 assert add(12, -2) == 10 assert add(-12, -2) == -14
def test_add(): assert add(2,3)==3
def test_hello_add(): assert add(test_hello_add.x) == 11
def test_add(): assert add(1, 2) == 3 assert add(3, 2) == 5 assert add(0, 0) == 0
def test_add(): assert 9 == add(4, 5)
def test_add(): assert 3 == add(1, 2)