更新时间:2023-11-29 15:08:46
我自己刚刚偶然发现了这个功能:您可以从 tests.py 中的抽象模型继承并照常进行测试.当您运行manage.py tests"时,Django 不仅会创建一个测试数据库,还会验证 &同步您的测试模型.
Just stumbled across this feature myself: You can just inherit from your abstract model in tests.py and test that as usual. When you run 'manage.py tests', Django not only creates a test database, but also validates & syncs your test models.
使用当前的 Django 主干(版本 1.2)对其进行了测试.
Tested it with current Django trunk (version 1.2).