随笔分类 - pytest笔记
摘要:File-Settings Tools-Python Intergrated Tools,Testing 选pytest,Apply 设置完成后,如果不能以pytest运行,继续操作,Edit Configurations 点-把现有模式全部删除 右键运行就会出现pytest了
阅读全文
摘要:运行发现 PytestUnknownMarkWarning: Unknown pytest.mark.auth - is this a typo? You can register custom marks to avoid this warning - for details, see https
阅读全文
摘要: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
阅读全文
摘要:@pytest.fixture(name="renamezhang") def some(): return 1 def test_someA(renamezhang): assert True
阅读全文
摘要:pytest --setup-show test_demo.py
阅读全文
摘要:@pytest.fixture(autouse=True) def some(): return 1 def test_someA(): assert True def test_someB(): assert True
阅读全文
摘要:@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): ...
阅读全文
摘要:#使用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): ...
阅读全文
摘要:pytest将每个fixture的执行分成SETUP和TEARDOWN两部分,测试被夹在中间。
阅读全文
摘要:#单个参数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
阅读全文
摘要:大部分资料中都说要在terminal终端运行,所以个人习惯直接写在os.system()里,相对上面的写法,下面这种就是终端怎么写这里怎么写就可以了。
阅读全文
摘要:x表示XFAIL,预期失败,实际也失败 X表示XPASS,预期失败,实际运行没有失败
阅读全文
摘要:直接运行看不到跳过原因,这时候可以使用 -rs pytest -rs test_demo4.py test session starts collected 3 items test_demo4.py ss. [100%] short test summary info SKIPPED [1] te
阅读全文
摘要:import pytest @pytest.mark.mark1 def test_markA(): assert True @pytest.mark.mark2 def test_markB(): assert True @pytest.mark.mark1 @pytest.mark.mark2 def test_markC(): assert True...
阅读全文
摘要:pytest ***.py 只运行某个文件 pytest 运行当前目录下的所有以test_开头,或以_test结尾的的测试函数 pytest [dir]/***.py [dir]/***.py 运行指定目录下的某个测试函数 pytest [dir] 运行指定目录下的所有测试函数 pytest [di
阅读全文
摘要:import pytest class TestCase(): def setup_class(self): print("setup_class:所有用例执行之前") def setup_method(self): print("setup_method: 每个用例开始前执行") def tear
阅读全文