做照片的网站,山西网站建设开发,别人用我公司权限做网站,运动网站建设教程基本用法##
pytest.main()函数是用于启动测试运行的入口点。它可以在命令行中直接使用#xff0c;也可以在脚本中以编程方式调用。 以下是一个简单的示例#xff1a;
import pytest
if __name____main__:pytest.main()执行当前目录下的所有测试文件
使用pytes…基本用法##
pytest.main()函数是用于启动测试运行的入口点。它可以在命令行中直接使用也可以在脚本中以编程方式调用。 以下是一个简单的示例
import pytest
if __name____main__:pytest.main()执行当前目录下的所有测试文件
使用pytest.main(‘目录名’)运行特定的测试模块
只想运行特定的测试模块。这可以通过向pytest.main()传递模块路径来实现。
import pytest
if __name__ __main__:pytest.main([practice/test_get.py]) //注意如果main函数所在的文件跟测试用例不在同一个目录需要指定一下不然会提示没有这个文件使用pytest.main(测试文件名:用例函数)运行特定的测试函数冒号分割 def test_one(self):assert 11def test_two(self):assert 21def test_three(self):assert 34import pytest
if __name__ __main__:pytest.main([practice/test_get.py::test_two])使用pytest.main()运行指定模块 指定类 指定用例冒号分割
pytest.main([‘test_reg.py::TestClass::test_method’]) pytest.main([practice/test_get.py::Test_Rule::test_two])//Test_Rule是类名test_two是用例函数其它参数
pytest.main([‘-vs’, ‘./test_case/test_demo.py::Test_case’])
-v: 丰富信息模式, 输出更详细的用例执行信息 -s: 显示程序中的print/logging输出 -q: 不输出环境信息
-mxxx: 运行打标签的用例 -rerunsxxx失败重新运行