Skip to content

Commit 1ee5e27

Browse files
committed
Fix testing with no server
1 parent 7eb4568 commit 1ee5e27

File tree

6 files changed

+7
-2
lines changed

6 files changed

+7
-2
lines changed

test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __init__(self):
121121
self.client = pymongo.MongoClient(host, port)
122122

123123
except pymongo.errors.ConnectionFailure:
124-
self.client = None
124+
self.client = self.rs_or_standalone_client = None
125125
else:
126126
self.connected = True
127127
self.ismaster = self.client.admin.command('ismaster')

test/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ClientUnitTest(unittest.TestCase):
7777
"""MongoClient tests that don't require a server."""
7878

7979
@classmethod
80+
@client_context.require_connection
8081
def setUpClass(cls):
8182
cls.client = MongoClient(host, port, connect=False,
8283
serverSelectionTimeoutMS=100)

test/test_collection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
class TestCollectionNoConnect(unittest.TestCase):
6666

6767
@classmethod
68+
@client_context.require_connection
6869
def setUpClass(cls):
6970
client = MongoClient(host, port, connect=False)
7071
cls.db = client.pymongo_test

test/test_cursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def test_add_remove_option(self):
130130
self.assertEqual(0, cursor._Cursor__query_flags)
131131

132132
# Exhaust - which mongos doesn't support
133-
if not self.db.client.is_mongos:
133+
if client_context.client is not None and not self.db.client.is_mongos:
134134
cursor = self.db.test.find(cursor_type=CursorType.EXHAUST)
135135
self.assertEqual(64, cursor._Cursor__query_flags)
136136
cursor2 = self.db.test.find().add_option(64)

test/test_database.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
class TestDatabaseNoConnect(unittest.TestCase):
6666

6767
@classmethod
68+
@client_context.require_connection
6869
def setUpClass(cls):
6970
cls.client = MongoClient(host, port, connect=False)
7071

test/test_grid_file.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from pymongo import MongoClient
3535
from pymongo.errors import ConfigurationError, ServerSelectionTimeoutError
3636
from test import (IntegrationTest,
37+
client_context,
3738
host,
3839
port,
3940
unittest,
@@ -44,6 +45,7 @@
4445
class TestGridFileNoConnect(unittest.TestCase):
4546

4647
@classmethod
48+
@client_context.require_connection
4749
def setUpClass(cls):
4850
client = MongoClient(host, port, connect=False)
4951
cls.db = client.pymongo_test

0 commit comments

Comments
 (0)