zoukankan      html  css  js  c++  java
  • python 备忘(外置模块)



    • 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 (定时任务框架)
    CLICK ME

    title
    https://blog.csdn.net/somezz/article/details/83104368

    
    

    • asyncio模块
    CLICK ME

    title

    
    

    • gevent模块
    CLICK ME

    title

    
    

    • Twisted模块
    CLICK ME

    title

    
    

    • thing
    CLICK ME

    title

    
    

    • thing
    CLICK ME

    title

    
    

  • 相关阅读:
    分享微云普通用户不限速下载方法
    PS基础之移动工具和分布对齐
    操作系统的概念、功能和目标
    又拍云+PicGo搭建图床教程
    05 数组
    04 循环结构
    02 数据类型_变量_运算符_表达式
    03 流程控制
    05 方法_递归
    win7下使用telnet的方法
  • 原文地址:https://www.cnblogs.com/amize/p/13265496.html
Copyright © 2011-2022 走看看