python - 自动化基础和标准工程介绍【含公共库介绍】(5)

1. 虚拟环境搭建

https://i.cnblogs.com/posts/edit;postId=15494484

 

2. 自动化标准工程

 

3. 公共库

3.1 sdet_common

                   是一个为自动化测试提供的公共库,主要做一些公共类的提供和公共方法的封装
                   前置准备   安装python环境: 下载python并安装,python版本要求:python 3.6及以上    安装公共库包
                                    安装:pip install sdet_common -i http://pypi.800best.cloud/repository/pypi-group/simple --trusted-host pypi.800best.cloud
                                    升级:pip install -U sdet_common -http://pypi.800best.cloud/repository/pypi-group/simple --trusted-host pypi.800best.cloud

3.2 主要模块

               HTTP请求模块: 包括POST请求、GET请求、文件上传
                get请求例子:
                                 from sdet_common.http.http_util import HttpUtil
                                 http_util = HttpUtil()
                                 data = {"id": "22233"}
                                 head = {"user": "132"}
                                 http_util.get("http://test.com", data, head, allow_redirects=False)

(3)字符或者字符串处理

                  包括:下划线和驼峰命名转换,随机生成常用号码,如:身份证,手机号等
                  Import路径:from sdet_common.str.str_util import StrUtil
                  主要方法
                                    camel_to_underline:驼峰转下划线
                                    underline_to_camel:下划线转驼峰
                                    get_id_number:身份证号生成
                                    get_phone_number:手机号生成
                                    get_credit_card_number:银行卡号生成
                                    get_uuid:uuid生成
                                    get_barcode:条码生成

(4)数据处理模块

                  包括字典比对(全量比对、包含比对)、列表比对、字典列表比对
                  Import路径:from sdet_common.data.data_util import DataUtil
                  主要方法:
                                     dict_equals_compare:简单字典严格对比,dict1和dict2严格相同
                                     dict_contains_compare:简单字典包含对比,dict1的所有key包含在dict2中,且value相等
                                     list_equals_compare:列表严格对比,list1和list2严格相同
                                     list_equals_compare_ignore_sequence:列表严格对比,list1和list2长度相等,且内容相同,顺序可不同
                                     list_contains_compare:列表包含对比,顺序相同,list1包含在list2中
                                     list_contains_compare_ignore_sequence:列表包含对比,顺序可不同,包含重复字段
                                     dict_list_value_contains_compare_ignore_sequence:字典列表包含对比, list1包含在list2中,且list1中的字典的key包含在list2的字典的key中,且value相等

(5)加密处理模块

                  包括AES加密、RSA加密、MD5加密、SHA256、BASE64加密
                  Import路径:from sdet_common.sdet_common.encrypt.encrypt_util import EncryptUtil
                   主要方法
                                   aes_encrypt:AES加密
                                   aes_decrypt:AES解密
                                   rsa_encrypt:RSA加密
                                   rsa_decrypt:RSA解密
                                   get_rsa_public_key:RSA根据模块和指数得到公钥
                                   md5_decrypt:MD5加密
                                   sha256_encrypt:SHA256加密
                                   base64_encrypt:BASE64加密
                                   base64_decrypt:BASE64解密

 

posted @ 2021-11-01 17:31  小丸子姐姐  阅读(79)  评论(0编辑  收藏  举报