Skip to content
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure order of sets in test
  • Loading branch information
Paul Jukic committed Oct 29, 2019
commit c6c0d77e6cf700d29b33f033cf7d921faecb66ca
15 changes: 9 additions & 6 deletions tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ class Test(Document):
assert Q( name__in={} ).toMongo( Test ) \
== {'name': {'$in': []}}

assert Q( name__in=set(['eggs', 'spam']) ).toMongo( Test ) \
== {'name': {'$in': ['eggs', 'spam']}}
# Python doesn't guarantee order. Should look like
# {'name': {'$in': ['eggs', 'span']}}
assert Q(name__in={'eggs', 'spam'}).toMongo(Test)['name']['$in'].sort() == ['eggs', 'spam'].sort()

# Clear objects so that counts will be correct
Test.objects.all( ).delete( )
Expand Down Expand Up @@ -417,8 +418,9 @@ class Test(Document):
assert Q( name__nin=[] ).toMongo( Test ) \
== {'name': {'$nin': []}}

assert Q( name__nin=['eggs', 'spam'] ).toMongo( Test ) \
== {'name': {'$nin': ['eggs', 'spam']}}
# Python doesn't guarantee order. Should look like
# {'name': {'$nin': ['eggs', 'spam']}}
assert Q( name__nin=['eggs', 'spam'] ).toMongo( Test )['name']['$nin'].sort() == ['eggs', 'spam'].sort()

# Clear objects so that counts will be correct
Test.objects.all( ).delete( )
Expand All @@ -441,8 +443,9 @@ class Test(Document):
assert Q( name__nin={} ).toMongo( Test ) \
== {'name': {'$nin': []}}

assert Q( name__nin=set(['eggs', 'spam']) ).toMongo( Test ) \
== {'name': {'$nin': ['eggs', 'spam']}}
# Python doesn't guarantee order. Should look like
# {'name': {'$nin': ['eggs', 'spam']}}
assert Q(name__nin={'eggs', 'spam'}).toMongo(Test)['name']['$nin'].sort() == ['eggs', 'spam'].sort()

# Clear objects so that counts will be correct
Test.objects.all( ).delete( )
Expand Down