<commit_before>'''
    Integration tests for backend locks.
'''

import etcd
import pylibmc
import redis
import sherlock
import time
import unittest


class TestRedisLock(unittest.TestCase):

    def setUp(self):
        try:
            self.client = redis.StrictRedis(host='redis')
        except Exception as err:
            print(str(err))
            raise Exception('You must have Redis server running on localhost '
                            'to be able to run integration tests.')
        self.lock_name = 'test_lock'

    def test_acquire(self):
        lock = sherlock.RedisLock(self.lock_name, client=self.client)
        self.assertTrue(lock._acquire())
        self.assertEqual(self.client.get(self.lock_name), str(lock._owner))

    def test_acquire_with_namespace(self):
        lock = sherlock.RedisLock(self.lock_name, client=self.client,
                                  namespace='ns')
        self.assertTrue(lock._acquire())
        self.assertEqual(self.client.get('ns_%s' % self.lock_name),
                         str(lock._owner))

    def test_acquire_once_only(self):
        lock1 = sherlock.RedisLock(self.lock_name, client=self.client)
        lock2 = sherlock.RedisLock(self.lock_name, client=self.client)
        self.assertTrue(lock1._acquire())
        self.assertFalse(lock2._acquire())<commit_msg>updates suggested by RyanGWU82<commit_after>'''
    Integration tests for backend locks.
'''

import etcd
import pylibmc
import redis
import sherlock
import time
import unittest


class TestRedisLock(unittest.TestCase):

    def setUp(self):
        try:
            self.client = redis.StrictRedis(host='redis') 
        except Exception as err:
            print(str(err))
            raise Exception('You must have Redis server running on localhost '
                            'to be able to run integration tests.')
        self.lock_name = 'test_lock'

    def test_acquire(self):
        lock = sherlock.RedisLock(self.lock_name, client=self.client)
        self.assertTrue(lock._acquire())
        self.assertEqual(self.client.get(self.lock_name), str(lock._owner))

    def test_acquire_with_namespace(self):
        lock = sherlock.RedisLock(self.lock_name, client=self.client,
                                  namespace='ns')
        self.assertTrue(lock._acquire())
        self.assertEqual(self.client.get('ns_%s' % self.lock_name),
                         str(lock._owner))

    def test_acquire_once_only(self):
        lock1 = sherlock.RedisLock(self.lock_name, client=self.client)
        lock2 = sherlock.RedisLock(self.lock_name, client=self.client)
        self.assertTrue(lock1._acquire())
        self.assertFalse(lock2._acquire())
{'fraction_non_alphanumeric': 0.10319227913882702, 'fraction_numerical': 0.003711952487008166, 'mean_word_length': 2.5790172642762283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2951536', 'n_tokens_mistral': 813, 'n_tokens_neox': 787, 'n_words': 154}