How do I test Django QuerySets are equal?

前端 未结 6 758
挽巷
挽巷 2020-12-17 07:40

I am trying to test my Django views. This view passes a QuerySet to the template:

def merchant_home(request, slug):
  merchant = Merchant.objects.get(slug=sl         


        
6条回答
  •  青春惊慌失措
    2020-12-17 08:26

    Use assertQuerysetEqual, which is built to compare the two querysets for you. You will need to subclass Django's django.test.TestCase for it to be available in your tests.

提交回复
热议问题