- ddt.py (数据驱动)
CLICK ME
show me the money code
import unittest
from ddt import ddt,data,unpack
@ddt
class MyTesting(unittest.TestCase):
'''打印 1 次:
test_a : [1, 2, 3]
'''
@data([1,2,3])
def test_a(self,value):
print('test_a :',value)
'''打印 3 次:
test_b : 1 ,
test_b : 2,
test_b : 3
'''
@data(1,2,3)
def test_b(self,value):
print('test_b :',value)
#程序报错无法运行,@unpack 无法解包
#add_test() argument after ** must be a mapping, not int
@data(1,2,3)
@unpack
def test_b(self,value):
print('test_b :',value)
'''打印 2 次:
test_c : [2, 3]
test_c : [4, 5]
'''
@data([2,3],[4,5])
def test_c(self,a):
print('test_c :', a)
#报错程序还能正常运行
#test_compare() missing 1 required positional argument: 'b'
@data([2,3],[4,5])
def test_compare(self,a,b):
print('test_compare :', a, b)
self.assertEqual(a,b)
'''打印 2 次:
test_d : 2 3
test_d : 4 5
'''
@data([2,3],[4,5])
@unpack
def test_d(self,a,b):
print('test_d :', a, b)
self.assertEqual(a,b)
'''打印 3 次:
test_minus : 3 2 1
test_minus : 5 3 2
test_minus : 10 4 6
'''
@data([3,2,1],[5,3,2],[10,4,6])
@unpack
def test_minus(self,a,b,expected):
print('test_minus :',a,b,expected)
actual = int(a) - int(b)
expected = int(expected)
self.assertEqual(actual, expected)
if __name__ == '__main__':
unittest.main(verbosity=2)
- apscheduler (定时任务框架)
- asyncio模块
CLICK ME
title
- gevent模块
CLICK ME
title
- Twisted模块
CLICK ME
title
- thing
CLICK ME
title
- thing
CLICK ME
title