<commit_before>#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<<EMAIL>>
#         http://binux.me
# Created on 2014-10-07 10:33:38

import os
import time
import unittest

from libs import utils
from libs import rabbitmq

@unittest.skipIf(os.environ.get('IGNORE_RABBITMQ'), 'no rabbitmq server for test.')
class TestRabbitMQ(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        with utils.timeout(3):
            self.q1 = rabbitmq.Queue('test_queue', maxsize=5)
            self.q2 = rabbitmq.Queue('test_queue', maxsize=5)

    @classmethod
    def tearDownClass(self):
        self.q2.delete()
        del self.q1
        del self.q2

    def test_10_put(self):
        self.assertEqual(self.q1.qsize(), 0)
        self.assertEqual(self.q2.qsize(), 0)
        self.q1.put('TEST_DATA1', timeout=3)
        self.q1.put('TEST_DATA2', timeout=3)
        time.sleep(0.01)
        self.assertEqual(self.q1.qsize(), 2)
        self.assertEqual(self.q2.qsize(), 2)

    def test_20_get(self):
        self.assertEqual(self.q1.get(timeout=0.01), 'TEST_DATA1')
        self.assertEqual(self.q2.get_nowait(), 'TEST_DATA2')
        with self.assertRaises(self.q1.Empty):
            self.q2.get(timeout=0.01)
        with self.assertRaises(self.q1.Empty):
            self.q2.get_nowait()

    def test_30_full(self):
        self.assertEqual(self.q1.qsize(), 0)
        self.assertEqual(self.q2.qsize(), 0)
        for i in range(2):
            self.q1.put_nowait('TEST_DATA%d' % i)
        for i in range(3):<commit_msg>add test for last bug<commit_after>#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<<EMAIL>>
#         http://binux.me
# Created on 2014-10-07 10:33:38

import os
import time
import unittest

from libs import utils
from libs import rabbitmq

@unittest.skipIf(os.environ.get('IGNORE_RABBITMQ'), 'no rabbitmq server for test.')
class TestRabbitMQ(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        with utils.timeout(3):
            self.q1 = rabbitmq.Queue('test_queue', maxsize=5)
            self.q2 = rabbitmq.Queue('test_queue', maxsize=5)

    @classmethod
    def tearDownClass(self):
        self.q2.delete()
        del self.q1
        del self.q2

    def test_10_put(self):
        self.assertEqual(self.q1.qsize(), 0)
        self.assertEqual(self.q2.qsize(), 0)
        self.q1.put('TEST_DATA1', timeout=3)
        self.q1.put('TEST_DATA2', timeout=3)
        time.sleep(0.01)
        self.assertEqual(self.q1.qsize(), 2)
        self.assertEqual(self.q2.qsize(), 2)

    def test_20_get(self):
        self.assertEqual(self.q1.get(timeout=0.01), 'TEST_DATA1')
        self.assertEqual(self.q2.get_nowait(), 'TEST_DATA2')
        with self.assertRaises(self.q1.Empty):
            self.q2.get()
        with self.assertRaises(self.q1.Empty):
            self.q2.get(timeout=0.01)
        with self.assertRaises(self.q1.Empty):
            self.q2.get_nowait()

    def test_30_full(self):
        self.assertEqual(self.q1.qsize(), 0)
        self.assertEqual(self.q2.qsize(), 0)
        for i in range(2):
            self.q1.put_nowait('TEST_DATA%d' % i)
        for i in range(3):
{'fraction_non_alphanumeric': 0.1435991445157348, 'fraction_numerical': 0.043996333638863426, 'mean_word_length': 2.601760176017602, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5286689', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1187, 'n_words': 212}