摘要:
Fixture,通常用来对测试方法、测试函数、测试类、测试文件 进行初始化 和还原测试环境 一、函数级 setup_function和teardown_function 这两个都是在普通方法前后执行,不作用于class里面的类方法 import pytest # 功能函数 def multiply( 阅读全文
posted @ 2020-12-06 16:13
打不死的强强强强
阅读(60)
评论(0)
推荐(0)
摘要:
断言:众所周知,unittest提供了丰富的断言方法,比如assertEqual()、assertIn()、assertTrue()等 但是,pytest没有提供专门的断言方法,而是使用了Python自带的assert断言,借助了Python的运算符号 和 关键字 轻松实现 不同数据类型 的断言。 阅读全文
posted @ 2020-12-06 11:57
打不死的强强强强
阅读(76)
评论(0)
推荐(0)
摘要:
.... 举个栗子: 1、创建一个test_sample.py文件 2、代码如下: def inc(x): return x + 1 def test_answer1(): assert inc(3) == 4 def test_answer2(): assert inc(3) == 5 3、运行测 阅读全文
posted @ 2020-12-06 11:31
打不死的强强强强
阅读(80)
评论(0)
推荐(0)
摘要:
.... 举个栗子: 1、创建一个test_sample.py文件 2、代码如下: def inc(x): return x + 1 def test_answer1(): assert inc(3) == 4 def test_answer2(): assert inc(3) == 5 3、运行测 阅读全文
posted @ 2020-12-06 11:21
打不死的强强强强
阅读(16)
评论(0)
推荐(0)

浙公网安备 33010602011771号