def __init__(self, *args, **kwargs): host = '127.0.0.1' port = 27017 user = '******' password = '******' db_name = 'test' client = pymongo.MongoClient(host, port) try: client[db_name].authenticate(user, password) except OperationFailure: client['admin'].authenticate(user, password) db = client[db_name] self.mr_client = MongoRedis(db, collection_name='cache_test') super(BaseTestCase, self).__init__(*args, **kwargs)
class BaseTestCase(unittest.TestCase): def __init__(self, *args, **kwargs): host = '127.0.0.1' port = 27017 user = '******' password = '******' db_name = 'test' client = pymongo.MongoClient(host, port) try: client[db_name].authenticate(user, password) except OperationFailure: client['admin'].authenticate(user, password) db = client[db_name] self.mr_client = MongoRedis(db, collection_name='cache_test') super(BaseTestCase, self).__init__(*args, **kwargs) def setUp(self): self.mr_client.flushdb() self.mr_client.start() def tearDown(self): self.mr_client.end()