I have a test where I'm trying to identify if I've successfully gotten an instance of a database using pymongo, and would like to use isinstance(obj, class) in an assertion. However I cant figure out how to get a class (not instance) of the database
I've tried several approaches. This seems closest but still no cigar:
import pymongo client = pymongo.MongoClient('localhost') database = client['test'] assert isinstance(database, pymongo.MongoClient.db_name)
which doesn't work since db_name isn't defined. Pymongo docs say a new database (reference?) is made using either
Of course these create an instance if I give it a db_name string, yet I want only the class, not an instance.