摘要:
bisect模块提供的功能: 一共包含四个函数 insort_right(a, x, lo=0, hi=None) bisect_right(a, x, lo=0, hi=None) insort_left(a, x, lo=0, hi=None) bisect_left(a, x, lo=0, h 阅读全文
摘要:
有时候我们需要初始化一个嵌套着几个列表的列表,这种情况下推荐使用列表推导式 代码1: def test01(): l = [["_"] * 3 for i in range(3)] print(l) l[1][2] = "x" print(l) if __name__ == '__main__': 阅读全文
摘要:
概况: 1、多个接口测试用例单线程执行很慢,需要用pytest-xdist插件提高执行速度; 2、存在session级别fixture,只能执行一次:执行登录等前置操作,获取token等全局数据,如果多次执行,则之前的token会失效 3、pytest-xdist插件没有实现session只执行一次 阅读全文
摘要:
import collections from random import choice Card = collections.namedtuple('Card',['rank','suit']) class FrenchDeck: ranks = [str(n) for n in range(2, 阅读全文
摘要:
1、指定范围的浮点数:random.uniform(1, 100) 2、指定小数位数进行四舍五入:random.uniform(1, 100), 7 3、string中的随机字符串: 4、由指定集合中的元素生成指定位数不重复的列表:random.sample(string.hexdigits, +4 阅读全文
摘要:
方式一:在线引用 前提:网络可以访问外网 在html文件的head中加入以下代码即可 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integ 阅读全文
摘要:
测试代码如下 from timeit import Timer def fun1(): a = [] for i in range(10000): li = [i] a = a + li def fun2(): a = [i for i in range(10000)] def fun3(): a 阅读全文
摘要:
一、前置条件 Linux服务器默认安装的是python2的环境; 不能将python2环境卸载了再装python3环境,这样可能会导致很多莫名其妙的问题,应该保持多个python环境 二、安装步骤 1、安装相关的依赖包 yum -y install zlib-devel bzip2-devel op 阅读全文
摘要:
一、环境准备: 1、安装allure 2、安装allure-pytest:pip install allure-pytest 二、allure基本参数说明 三、实践代码 #conftest.py import pytest @pytest.fixture(scope="session") def l 阅读全文