Skip to content

Commit

Permalink
Fixing doctest predictability
Browse files Browse the repository at this point in the history
  • Loading branch information
heynemann committed Jun 29, 2014
1 parent e005bb1 commit 0fab04e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ tox3:
toxpypy:
@PATH=$$PATH:~/.pythonbrew/pythons/Python-2.6.*/bin/:~/.pythonbrew/pythons/Python-2.7.*/bin/:~/.pythonbrew/pythons/Python-3.0.*/bin/:~/.pythonbrew/pythons/Python-3.1.*/bin/:~/.pythonbrew/pythons/Python-3.2.3/bin/:~/.pythonbrew/pythons/Python-3.3.0/bin/ tox -e pypy

clean:
@rm -rf ./docs/build/
@rm -rf ./build
@find . -name '*.pyc' -delete

clean-doc:
@cd docs && make clean

Expand Down
13 changes: 8 additions & 5 deletions docs/source/getting-and-querying.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ Let's look at an example of querying for a more specific document. Say we want t

query_result = query.to_query(User)

print(query_result)
# the resulting query should be similar to:
# {'$or': [{'last_update': None}, {'is_active': True, 'last_update': {'$lt': datetime.datetime(2010, 1, 1, 0, 0)}}]}

The resulting query is:
assert '$or' in query_result

.. testoutput:: querying_with_Q_and_or

{'$or': [{'last_update': None}, {'is_active': True, 'last_update': {'$lt': datetime.datetime(2010, 1, 1, 0, 0)}}]}
or_query = query_result['$or']
assert len(or_query) == 2
assert 'last_update' in or_query[0]
assert 'is_active' in or_query[1]
assert 'last_update' in or_query[1]

Query Operators
---------------
Expand Down
14 changes: 6 additions & 8 deletions motorengine/query/is_null.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ class User(Document):
query_result = query.to_query(User)
print(query_result)
# query results should be like:
# {'email': {'$ne': None, '$exists': True}}
The resulting query is:
.. testoutput:: isnull_query_operator
{'email': {'$ne': None, '$exists': True}}
'''
assert 'email' in query_result
assert '$ne' in query_result['email']
assert '$exists' in query_result['email']
r '''

def to_query(self, field_name, value):
if value:
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
'ipdb',
'coveralls',
'mongoengine',
'docutils',
'jinja2',
'sphinx',
]

Expand Down

0 comments on commit 0fab04e

Please sign in to comment.