Django: Best way to unit-test an abstract model

后端 未结 13 1270
一个人的身影
一个人的身影 2020-12-24 12:28

I need to write some unit tests for an abstract base model, that provides some basic functionality that should be used by other apps. It it would be necessary to define a mo

13条回答
  •  有刺的猬
    2020-12-24 13:16

    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.

    Tested it with current Django trunk (version 1.2).

提交回复
热议问题