conftest.py 是规定的文件名写法,配置文件和pytest.ini一样
目录结构
写了2个配置文件,一个跟目录,一个在basics2目录下
跟目录下的conftest.py
basics2目录下的conftest.py
basics2目录下的用例
运行前后置
代码
import pytest #括号里面的顺序代表先执行前置的顺序 def test(all_fixture,basics2_fixture): print("测试conftest.py和fixture的配合使用") if __name__ == '__main__': pytest.main([r'D:\python新代码集\pytest_study\basics2\test_fixture_conftest.py'])
结果