From 9b2fde962c09eaf22520cf1eeb268e08dce29bc8 Mon Sep 17 00:00:00 2001 From: mrigal Date: Thu, 16 Apr 2015 13:14:20 +0200 Subject: [PATCH] added try except to geo test to catch random mongo internal errors --- tests/queryset/geo.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/queryset/geo.py b/tests/queryset/geo.py index dad51132..12e96a04 100644 --- a/tests/queryset/geo.py +++ b/tests/queryset/geo.py @@ -1,14 +1,16 @@ import sys -from mongoengine.connection import get_connection sys.path[0:0] = [""] import unittest from datetime import datetime, timedelta -from mongoengine import * +from pymongo.errors import OperationFailure +from mongoengine import * +from mongoengine.connection import get_connection from nose.plugins.skip import SkipTest + __all__ = ("GeoQueriesTest",) @@ -175,6 +177,13 @@ class GeoQueriesTest(unittest.TestCase): points = Point.objects(location__near_sphere=[-122, 37.5], location__max_distance=60 / earth_radius) + # This test is sometimes failing with Mongo internals non-sense. + # See https://travis-ci.org/MongoEngine/mongoengine/builds/58729101 + try: + points.count() + except OperationFailure: + raise SkipTest("Sometimes MongoDB ignores its capacities on maxDistance") + self.assertEqual(points.count(), 2) # Finds both points, but orders the north point first because it's