摘要: 1 import random 2 3 4 print(random.randint(1, 10)) # 产生 1 到 10 的一个整数型随机数 5 print(random.random()) # 产生 0 到 1 之间的随机浮点数 6 print(random.uniform(1.1, 5.4) 阅读全文
posted @ 2022-03-21 14:23 WJ-HAHA 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 抽象出测试用例基类 3 1. 提取Excel文件中的用例数据 4 2. 自动处理鉴权请求头 5 3. 生成一个没有被使用的手机号码 6 """ 7 import unittest 8 import settings 9 10 from common.request_handler i 阅读全文
posted @ 2022-03-21 13:17 WJ-HAHA 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 1 import pymysql 2 import settings 3 4 5 class DB: 6 def __init__(self, **kwargs): 7 self.conn = pymysql.connect(**kwargs) 8 self.cursor = self.conn.c 阅读全文
posted @ 2022-03-21 13:12 WJ-HAHA 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 在根目录下添加配置文件settings.py文件,用于存放项目中可一些配置化的参数 """ 配置文件 """ import os # 项目根目录 # 配置文件的绝对路径 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # 项目的HOST P 阅读全文
posted @ 2022-03-21 12:05 WJ-HAHA 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 日志处理器 3 """ 4 5 import logging 6 import settings 7 8 9 def get_logger(name='WJ-test', file='WJ-test.log', 10 fmt='%(levelname)s %(asctime)s [% 阅读全文
posted @ 2022-03-21 11:55 WJ-HAHA 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 1 import requests 2 3 4 def send_request(url, method='GET', **kwargs): 5 """ 6 发送请求 7 :param url: 8 :param method: 请求方法 9 :param kwargs: 接收request原生请求 阅读全文
posted @ 2022-03-21 10:46 WJ-HAHA 阅读(49) 评论(0) 推荐(0) 编辑
摘要: 1 import pymysql 2 3 # 1. 创建连接 4 conn = pymysql.Connect( 5 host='数据库连接地址', 6 user='账号', 7 password='密码', 8 db='库名', 9 charset='utf8', 10 ) 11 print(co 阅读全文
posted @ 2022-03-21 10:26 WJ-HAHA 阅读(24) 评论(0) 推荐(0) 编辑