コード例 #1
0
 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)
コード例 #2
0
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()