阅读背景:

模拟Django Queryset,以测试接受Queryset的函数

来源:互联网 

I have a utility function in my Django project, it takes a queryset, gets some data from it and returns a result. I'd like to write some tests for this function. Is there anyway to 'mock' a QuerySet? I'd like to create an object that doesn't touch the database, and i can provide it with a list of values to use (i.e. some fake rows) and then it'll act just like a queryset, and will allow someone to do field lookups on it/filter/get/all etc.I have a utility function in my Django project,




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: