摘要: import pytest #parametrize参数化 @pytest.mark.parametrize("A", [1, 2, 3, 4, 5]) def test_A(A): assert A > 3 #fixture参数化 B = [1, 2, 3, 4, 5] ids = ['a','b','c','d','e'] @pytest.fixture(params=B,ids=ids) d 阅读全文
posted @ 2019-08-21 17:57 OTAKU_nicole 阅读(979) 评论(0) 推荐(0) 编辑
摘要: @pytest.fixture(name="renamezhang") def some(): return 1 def test_someA(renamezhang): assert True 阅读全文
posted @ 2019-08-21 17:56 OTAKU_nicole 阅读(244) 评论(0) 推荐(0) 编辑
摘要: pytest --setup-show test_demo.py 阅读全文
posted @ 2019-08-21 17:55 OTAKU_nicole 阅读(548) 评论(0) 推荐(0) 编辑
摘要: @pytest.fixture(autouse=True) def some(): return 1 def test_someA(): assert True def test_someB(): assert True 阅读全文
posted @ 2019-08-21 17:55 OTAKU_nicole 阅读(711) 评论(0) 推荐(0) 编辑
摘要: @pytest.fixture() def some_A(): return 1 @pytest.fixture() def some_B(some_A): return some_A+1 @pytest.fixture() def some_C(some_A,some_B): return some_A+some_B def test_some(some_C): ... 阅读全文
posted @ 2019-08-21 17:54 OTAKU_nicole 阅读(537) 评论(0) 推荐(0) 编辑
摘要: #使用usefixtures和在测试方法中添加fixture参数差不多,但是只有后者才能用使用fix的返回值 @pytest.fixture() def some_data(): return (1,"a",None,{"b": 2}) def test_A(some_data): assert some_data[0]==1 def test_B(some_data): ... 阅读全文
posted @ 2019-08-21 17:53 OTAKU_nicole 阅读(991) 评论(0) 推荐(0) 编辑
摘要: pytest将每个fixture的执行分成SETUP和TEARDOWN两部分,测试被夹在中间。 阅读全文
posted @ 2019-08-21 17:52 OTAKU_nicole 阅读(134) 评论(0) 推荐(0) 编辑
摘要: #单个参数A @pytest.mark.parametrize("A", [1, 2, 3, 4, 5]) def test_A(A): assert A > 3 #多个参数 @pytest.mark.parametrize("F,G,H", ([(1,2,3), (4,5,6), (7,8,9)])) def test_F(F,G,H): assert F+G>H #多个参数换个写法 @pyte 阅读全文
posted @ 2019-08-21 14:38 OTAKU_nicole 阅读(806) 评论(0) 推荐(0) 编辑
摘要: 大部分资料中都说要在terminal终端运行,所以个人习惯直接写在os.system()里,相对上面的写法,下面这种就是终端怎么写这里怎么写就可以了。 阅读全文
posted @ 2019-08-21 10:38 OTAKU_nicole 阅读(2175) 评论(0) 推荐(0) 编辑