from django.test import TestCase
from django.core.management import call_command
class GlobalSetup(TestCase):
def setUp(self):
# Manually calling loaddata to import fixures
# that are not in INSTALLED_APPS
call_command('loaddata', 'cur_dir/fixtures_name', verbosity=0)
Just had to programmatically call 'loaddata' using call_command. You can do it in setUp.
from django.test import TestCase
from django.core.management import call_command
class GlobalSetup(TestCase):
def setUp(self):
# Manually calling loaddata to import fixures
# that are not in INSTALLED_APPS
call_command('loaddata', 'cur_dir/fixtures_name', verbosity=0)
发布评论
评论(2)
您可以使用
FIXTURE_DIRS
设置定义其他位置来搜索灯具:https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRSYou can define additional locations to search for fixtures using the
FIXTURE_DIRS
setting: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS只需使用 call_command 以编程方式调用“loaddata”。你可以在setUp中完成。
Just had to programmatically call 'loaddata' using call_command. You can do it in setUp.