摘要: Fixture(夹具) 夹具(Fixture)是一些函数,pytest 会在执行测试函数之前(或之后)加载运行它们。(夹具--上下夹住模块,程序从上向下运行,可以使模块进行预处理和后处理) 我们可以利用夹具做任何事情,其中最常见的可能就是数据库的初始连接和最后关闭操作。 Pytest 使用 pyte 阅读全文
posted @ 2021-07-15 09:06 Gex 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 如果我们事先知道测试函数会执行失败,但又不想直接跳过,而是希望显示的提示。 Pytest 使用 pytest.mark.xfail 实现预见错误功能: # test_xfail.py @pytest.mark.xfail(gen.__version__ < '0.2.0', reason='not 阅读全文
posted @ 2021-07-13 17:56 Gex 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 第一次(或n次)故障后停止 在第一(n)次失败后停止测试过程: pytest -x # stop after first failure pytest --maxfail=2 # stop after two failures 指定测试/选择测试 pytest支持几种方法来运行和从命令行中选择测试。 阅读全文
posted @ 2021-07-13 17:48 Gex 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 最近看了许多Pytest的文档,发现有些已经是很早以前的版本了。沿着学习的道路,我记录下我学习Pytest的过程 安装 pip install pytest 安装很简单,如果第一次安装用上述pip安装,如果已经安装了使用 pip install -U pytest -U参数具有更新作用 我的使用环境 阅读全文
posted @ 2021-07-13 16:00 Gex 阅读(55) 评论(0) 推荐(0) 编辑
摘要: sorted() 函数对所有可迭代的对象进行排序操作。 sort 与 sorted 区别: sort 是应用在 list 上的方法,sorted 可以对所有可迭代的对象进行排序操作。 list 的 sort 方法返回的是对已经存在的列表进行操作,无返回值,而内建函数 sorted 方法返回的是一个新 阅读全文
posted @ 2021-07-09 18:11 Gex 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 名称 关键字 用法 创建 create 创建库:create database 数据库名; 创建表:create table 表名 (列名 列类型……); 删除 drop 删除库:drop database 数据库名; 删除表: drop table 表名; 选择 use use 数据库/表; 增 阅读全文
posted @ 2021-07-09 16:30 Gex 阅读(125) 评论(0) 推荐(0) 编辑
摘要: def fab(max): n, a, b = 0, 0, 1 while n < max: print(b) a = b b = a + b n = n + 1 fab(10) 输出 1 1 2 4 8 16 32 64 128 256 而 def fab(max): n, a, b = 0, 0 阅读全文
posted @ 2021-06-23 16:51 Gex 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 今天有学了,记录下 all(iterable) 描述 all() 函数用于判断给定的可迭代参数 iterable 中的所有元素是否都为 TRUE,如果是返回 True,否则返回 False。 元素除了是 0、空、None、False 外都算 True。 函数等价于: def all(iterable 阅读全文
posted @ 2021-06-23 11:32 Gex 阅读(117) 评论(0) 推荐(0) 编辑
摘要: https://www.cnblogs.com/lincappu/p/12801817.html 阅读全文
posted @ 2021-06-23 00:16 Gex 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 该模块提供了许多对文件和文件集合的高级操作。特别是提供了支持文件复制和删除的功能。对于单个文件的操作,另见 模块。shutilos shutil.copyfile( src , dst , * , follow_symlinks=True ) 将名为src的文件的内容(无元数据)复制到名为dst的文 阅读全文
posted @ 2021-06-22 23:51 Gex 阅读(96) 评论(0) 推荐(0) 编辑