removed sleep thanks to @seglberg suggestion
This commit is contained in:
parent
c5ed308ea5
commit
f4478fc762
@ -1,5 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
from time import sleep
|
import datetime
|
||||||
|
|
||||||
sys.path[0:0] = [""]
|
sys.path[0:0] = [""]
|
||||||
|
|
||||||
@ -8,8 +8,6 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
import pymongo
|
import pymongo
|
||||||
from bson.tz_util import utc
|
from bson.tz_util import utc
|
||||||
|
|
||||||
@ -62,8 +60,12 @@ class ConnectionTest(unittest.TestCase):
|
|||||||
connect('mongoenginetest', alias='testdb2')
|
connect('mongoenginetest', alias='testdb2')
|
||||||
actual_connection = get_connection('testdb2')
|
actual_connection = get_connection('testdb2')
|
||||||
|
|
||||||
# horrible, but since PyMongo3+, connection are created asynchronously
|
# Handle PyMongo 3+ Async Connection
|
||||||
sleep(0.1)
|
if IS_PYMONGO_3:
|
||||||
|
# Ensure we are connected, throws ServerSelectionTimeoutError otherwise.
|
||||||
|
# Purposely not catching exception to fail test if thrown.
|
||||||
|
expected_connection.server_info()
|
||||||
|
|
||||||
self.assertEqual(expected_connection, actual_connection)
|
self.assertEqual(expected_connection, actual_connection)
|
||||||
|
|
||||||
def test_connect_uri(self):
|
def test_connect_uri(self):
|
||||||
@ -207,8 +209,11 @@ class ConnectionTest(unittest.TestCase):
|
|||||||
self.assertEqual(mongo_connections['t1'].host, 'localhost')
|
self.assertEqual(mongo_connections['t1'].host, 'localhost')
|
||||||
self.assertEqual(mongo_connections['t2'].host, '127.0.0.1')
|
self.assertEqual(mongo_connections['t2'].host, '127.0.0.1')
|
||||||
else:
|
else:
|
||||||
# horrible, but since PyMongo3+, connection are created asynchronously
|
# Handle PyMongo 3+ Async Connection
|
||||||
sleep(0.1)
|
# Ensure we are connected, throws ServerSelectionTimeoutError otherwise.
|
||||||
|
# Purposely not catching exception to fail test if thrown.
|
||||||
|
mongo_connections['t1'].server_info()
|
||||||
|
mongo_connections['t2'].server_info()
|
||||||
self.assertEqual(mongo_connections['t1'].address[0], 'localhost')
|
self.assertEqual(mongo_connections['t1'].address[0], 'localhost')
|
||||||
self.assertEqual(mongo_connections['t2'].address[0], '127.0.0.1')
|
self.assertEqual(mongo_connections['t2'].address[0], '127.0.0.1')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user