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
By default assertQuerysetEqual
uses repr()
on the first argument. This is why you were having issues with the strings in the queryset comparison.
To work around this you can override the transform argument with a lambda
function that doesn't use repr()
:
self.assertQuerysetEqual(queryset_1, queryset_2, transform=lambda x: x)