-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 3.0.3
-
Component/s: None
-
None
Sometimes I connect a local mongos to our production environment to be able to debug something with live data. This is potentially risky if I forget this process and run our test suite later when I fixed the bug, which is why I have the following code in the module level of our test suite:
tests/_init_.py
c = MongoClient("mongodb://localhost:27017") if c.is_mongos: raise Exception("Connected to a local Mongos instance, need a mongod")
As of upgrading to pymongo 3, this will return False before a connection is established, making this check worthless for the purpose above. For now, I've added c.server_info() before the c.is_mongos check, but I really think it should raise an exception or ensure a connection before returning an answer. Have not checked the other is_* properties as I don't use them, but maybe the problem exists there as well.