You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the discussion of how to compare Q objects in Django unit tests, there are some alternative methods that can be used which you do not cover.
Here are some examples where you can test the contents of a Django Q object for single Q objects, compound AND/OR Q objects, and you can also test the contents of a Q object in case you have a situation where the order of the results are non-deterministic (e.g. you are using a set to hold some values that build the object).
In these examples, the Q object is being returned by an external query builder function based on a list of values.
What version of Django are you using? These posts were written about the time of Django 1.8 when Q objects did not implement __cmp__ and so using assertEqual() would not work - hence the reason for the post.
In your page here:
https://jamescooke.info/comparing-django-q-objects.html
https://github.com/jamescooke/blog/blob/d31e4ef3abed4985fa9cc9c567590e9cdfda13b4/content/1603-comparing-django-q-objects.rst
On the discussion of how to compare Q objects in Django unit tests, there are some alternative methods that can be used which you do not cover.
Here are some examples where you can test the contents of a Django Q object for single Q objects, compound AND/OR Q objects, and you can also test the contents of a Q object in case you have a situation where the order of the results are non-deterministic (e.g. you are using a
set
to hold some values that build the object).In these examples, the Q object is being returned by an external query builder function based on a list of values.
The text was updated successfully, but these errors were encountered: