How to use the redislite.patch.patch_redis_StrictRedis function in redislite

To help you get started, we’ve selected a few redislite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yahoo / redislite / tests / test_patch.py View on Github external
def test_redislite_patch_redis_StrictRedis(self):
        redislite.patch.patch_redis_StrictRedis()
        r = redis.StrictRedis()
        self._log_redis_pid(r)
        self.assertIsInstance(r.pid, int)    # Should have a redislite pid
        redislite.patch.unpatch_redis_StrictRedis()
github yahoo / redislite / tests / test_patch.py View on Github external
def test_redislite_patch_strictredis_with_dbfile(self):
        dbfilename = os.path.join(
            self.tempdir,
            'test_redislite_patch_redis_with_short_dbfile.db'
        )
        if os.path.exists(dbfilename):
            os.remove(dbfilename)
        redislite.patch.patch_redis_StrictRedis(dbfilename)
        r = redis.StrictRedis()
        self._log_redis_pid(r)
        self.assertIsInstance(r.pid, int)    # Should have a redislite pid
        s = redis.StrictRedis()
        self._log_redis_pid(s)
        self.assertIsInstance(r.pid, int)    # Should have a redislite pid

        # Both instances should be talking to the same redis server
        self.assertEqual(r.pid, s.pid)
        redislite.patch.unpatch_redis_StrictRedis()
        r._cleanup()
        s._cleanup()
        if os.path.exists(dbfilename):
            os.remove(dbfilename)