我正在使用pytest-django为django应用程序编写单元测试。我想让我的测试更有性能,这样做需要我将数据保存在数据库中一段时间,而不是只在一次测试后丢弃它。例如: @pytest.mark.django_db p1 = MyModel.objects.create(description="some description") # this object has the id 1def tes
我有在conftest.py中定义的公共fixture,它在所有模块之间共享,范围是'function‘作用域,如下所示: conftest.py @pytest.fixture(scope="function# resets the state of the services 我的测试当前调用它,如下所示, test_module_one: # change scope to session here
我正在使用pytest为一个可以在本地和云中运行的软件编写功能测试。我想创建两个模块,每个模块都有相同的模块/装置名称,并让pytest加载一个或另一个,这取决于我是在本地运行测试还是在云中运行测试:/fixtures/__init__.pyimport pytestdef my_fixture():
return T