From 553f496d847ce51018e8df591c1fd4052fbbcbed Mon Sep 17 00:00:00 2001 From: Stefan Wojcik Date: Tue, 13 Dec 2016 00:42:03 -0500 Subject: [PATCH] fix tests --- tests/test_connection.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index 34168b85..9143571f 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -202,10 +202,16 @@ class ConnectionTest(unittest.TestCase): def test_connect_uri_with_replicaset(self): """Ensure connect() works when specifying a replicaSet.""" - c = connect(host='mongodb://localhost/test?replicaSet=local-rs') - db = get_db() - self.assertTrue(isinstance(db, pymongo.database.Database)) - self.assertEqual(db.name, 'test') + if IS_PYMONGO_3: + c = connect(host='mongodb://localhost/test?replicaSet=local-rs') + db = get_db() + self.assertTrue(isinstance(db, pymongo.database.Database)) + self.assertEqual(db.name, 'test') + else: + # PyMongo < v3.x raises an exception: + # "localhost:27017 is not a member of replica set local-rs" + with self.assertRaises(MongoEngineConnectionError): + c = connect(host='mongodb://localhost/test?replicaSet=local-rs') def test_uri_without_credentials_doesnt_override_conn_settings(self): """Ensure connect() uses the username & password params if the URI