22👍
✅
try this:
self.assertQuerysetEqual(
tree_record_qs,
[repr(r) for r in tree_record_backup]
)
it’s a bit weird and undocumented; but, that should work for you.
36👍
assertQuerysetEqual
takes a queryset
, a list of values and a transform
callable which is called on the queryset to convert it into something comparable to the list of values. By default this callable is repr
. This is kind of irritating since it doesn’t actually compare two querysets, but the easy fix for most cases is using map(repr, your_second_queryset)
for the list of values. This is documented in django since version 1.3.
- [Django]-Django: Difference between BASE_DIR and PROJECT_ROOT?
- [Django]-How to validate uniqueness constraint across foreign key (django)
- [Django]-Django user_passes_test decorator
Source:stackexchange.com