如何注册仅存在于unittest中的自定义Django管理命令?你知道吗
在Django 1.5中,您可以这样做:
from django.test import TestCase
from django.core.management import _commands
from myapp.testse.commands import MyTestCommand
class JobTestCase(TestCase):
fixtures = ['test_jobs.json']
def setUp(self):
# Install the test command; this little trick installs the command
# so that we can refer to it by name
_commands['test_command'] = MyTestCommand()
但是,在django1.8中,_commands
不再存在。从代码中看,现在似乎可以通过django.core.management公司.getu命令,但我没有看到添加或注册任意命令类的方法。这可能吗?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐