Skip to content
Browse files

Fix testing with no server

1 parent 7eb4568 commit 1ee5e27f9a5b63648f9b09253520717dd1e9e367 @behackett behackett committed Jun 24, 2016
Showing with 7 additions and 2 deletions.
  1. +1 −1 test/__init__.py
  2. +1 −0 test/test_client.py
  3. +1 −0 test/test_collection.py
  4. +1 −1 test/test_cursor.py
  5. +1 −0 test/test_database.py
  6. +2 −0 test/test_grid_file.py
View
2 test/__init__.py
@@ -121,7 +121,7 @@ def __init__(self):
self.client = pymongo.MongoClient(host, port)
except pymongo.errors.ConnectionFailure:
- self.client = None
+ self.client = self.rs_or_standalone_client = None
else:
self.connected = True
self.ismaster = self.client.admin.command('ismaster')
View
1 test/test_client.py
@@ -77,6 +77,7 @@ class ClientUnitTest(unittest.TestCase):
"""MongoClient tests that don't require a server."""
@classmethod
+ @client_context.require_connection
def setUpClass(cls):
cls.client = MongoClient(host, port, connect=False,
serverSelectionTimeoutMS=100)
View
1 test/test_collection.py
@@ -65,6 +65,7 @@
class TestCollectionNoConnect(unittest.TestCase):
@classmethod
+ @client_context.require_connection
def setUpClass(cls):
client = MongoClient(host, port, connect=False)
cls.db = client.pymongo_test
View
2 test/test_cursor.py
@@ -130,7 +130,7 @@ def test_add_remove_option(self):
self.assertEqual(0, cursor._Cursor__query_flags)
# Exhaust - which mongos doesn't support
- if not self.db.client.is_mongos:
+ if client_context.client is not None and not self.db.client.is_mongos:
cursor = self.db.test.find(cursor_type=CursorType.EXHAUST)
self.assertEqual(64, cursor._Cursor__query_flags)
cursor2 = self.db.test.find().add_option(64)
View
1 test/test_database.py
@@ -65,6 +65,7 @@
class TestDatabaseNoConnect(unittest.TestCase):
@classmethod
+ @client_context.require_connection
def setUpClass(cls):
cls.client = MongoClient(host, port, connect=False)
View
2 test/test_grid_file.py
@@ -34,6 +34,7 @@
from pymongo import MongoClient
from pymongo.errors import ConfigurationError, ServerSelectionTimeoutError
from test import (IntegrationTest,
+ client_context,
host,
port,
unittest,
@@ -44,6 +45,7 @@
class TestGridFileNoConnect(unittest.TestCase):
@classmethod
+ @client_context.require_connection
def setUpClass(cls):
client = MongoClient(host, port, connect=False)
cls.db = client.pymongo_test

0 comments on commit 1ee5e27

Please sign in to comment.
Something went wrong with that request. Please try again.