Mocking a Django Queryset in order to test a function that takes a queryset

前端 未结 9 1302
青春惊慌失措
青春惊慌失措 2020-12-28 13:55

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 a

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-28 14:35

    Not that I know of, but why not use an actual queryset? The test framework is all set up to allow you to create sample data within your test, and the database is re-created on every test, so there doesn't seem to be any reason not to use the real thing.

提交回复
热议问题