2024-04-29 13:43:10 发布
网友
我已经使用dumpdata django命令将开发环境中的数据转储到yaml文件中
我正在使用pytest框架,需要实现以下场景:
是否有任何插件或挂钩,我可以用来实现上述
我使用的是python 3.8、pytest 6.2.4、pytest django 4.40和django 3.0.5
如果您正在使用pytest-django包,那么您可以通过在conftest.py中提供一个^{} fixturepytestfixture来为您的测试加载Django数据装置
pytest-django
conftest.py
import pytest from django.core.management import call_command @pytest.fixture(scope='session') def django_db_setup(django_db_setup, django_db_blocker): with django_db_blocker.unblock(): call_command('loaddata', 'my_fixture.yaml')
如果您正在使用} fixture pytestfixture来为您的测试加载Django数据装置
pytest-django
包,那么您可以通过在conftest.py
中提供一个^{相关问题 更多 >
编程相关推荐