diff --git a/mongoengine/context_managers.py b/mongoengine/context_managers.py index c6d0d40f..150f9657 100644 --- a/mongoengine/context_managers.py +++ b/mongoengine/context_managers.py @@ -1,7 +1,7 @@ from mongoengine.common import _import_class -from mongoengine.connection import DEFAULT_CONNECTION_NAME, get_db -from pymongo.write_concern import WriteConcern from contextlib import contextmanager +from pymongo.write_concern import WriteConcern +from mongoengine.connection import DEFAULT_CONNECTION_NAME, get_db __all__ = ('switch_db', 'switch_collection', 'no_dereference', diff --git a/mongoengine/document.py b/mongoengine/document.py index 865bb063..2de0b1a3 100644 --- a/mongoengine/document.py +++ b/mongoengine/document.py @@ -854,7 +854,7 @@ class Document(BaseDocument): collection = cls._get_collection() # 746: when connection is via mongos, the read preference is not necessarily an indication that # this code runs on a secondary - if not collection.database.client.is_mongos and collection.read_preference > 1: + if not collection.is_mongos and collection.read_preference > 1: return # determine if an index which we are creating includes diff --git a/tox.ini b/tox.ini index 9bb0c5ec..2f2b1757 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,11 @@ [tox] -envlist = {py27,py35,pypy,pypy3}-{mg27,mg28,mg35,mg3x} +envlist = {py27,py35,pypy,pypy3}-{mg35,mg3x} [testenv] commands = python setup.py nosetests {posargs} deps = nose - mg27: PyMongo<2.8 - mg28: PyMongo>=2.8,<2.9 mg35: PyMongo==3.5 mg3x: PyMongo>=3.0 setenv =