为django创建不引人注目的测试模型。
django-whatever的Python项目详细描述
django whatever是mikhail podgurskiy(kmmbvnr)编写的django-any包的友好分叉 fork的目的是修复大多数恼人的错误并添加some features 若要与原始包保持兼容,django-whatever将保留相同的命名空间:django_any。
django-whatever是旧样式的显式替换,大且容易出错 隐式夹具文件。
django-whatever只允许指定对测试重要的字段 并用可接受的值随机填充其余的值。
它使测试变得简洁易懂,无需读取fixture文件。
from django_any import any_model class TestMyShop(TestCase): def test_order_updates_user_account(self): account = any_model(Account, amount=25, user__is_active=True) order = any_model(Order, user=account.user, amount=10) order.proceed() account = Account.objects.get(pk=account.pk) self.assertEquals(15, account.amount)
阅读文档:http://django-whatever.readthedocs.org/