<commit_before># -*- coding: utf-8 -*-

from __future__ import with_statement

import time
import socket

import msgpack
import pytest
from mock import MagicMock, patch, call

from pyfluent import client

import sys
if sys.version_info[:2] <= (2, 5):
    next = lambda iter: iter.next()


def test_geometric_sequence():
    gs = client.geometric_sequence()
    assert [next(gs) for x in range(8)] == [
        1.0, 2.0, 4.0, 8.0, 16.0, 30.0, 30.0, 30.0
    ]
    gs = client.geometric_sequence(2.0, 1.5, 60.0)
    assert [next(gs) for x in range(8)] == [
        2.0, 3.0, 4.5, 6.75, 10.125, 15.1875, 22.78125, 34.171875
    ]


class TestFluentSender(object):
    def pytest_funcarg__sender(self, request):
        return client.FluentSender('test')

    def pytest_funcarg__msgs(self, request):
        return [
            {'message': 'test1'}, {'message': 'test2'}, {'message': 'test3'}
        ]

    def test_init(self, sender):
        assert sender.default_tag == 'test'
        assert sender.host == 'localhost'
        assert sender.port == 24224
        assert sender.timeout == 1
        assert sender._retry_time == 0
        assert sender._queue.maxlen == None
        assert isinstance(sender.packer, msgpack.Packer)

    def test_make_socket(self, sender):<commit_msg>fix test for python 2.6 support<commit_after># -*- coding: utf-8 -*-

from __future__ import with_statement

import time
import socket

import msgpack
import pytest
from mock import MagicMock, patch, call

from pyfluent import client

import sys
if sys.version_info[:2] <= (2, 5):
    next = lambda iter: iter.next()


def test_geometric_sequence():
    gs = client.geometric_sequence()
    assert [next(gs) for x in range(8)] == [
        1.0, 2.0, 4.0, 8.0, 16.0, 30.0, 30.0, 30.0
    ]
    gs = client.geometric_sequence(2.0, 1.5, 60.0)
    assert [next(gs) for x in range(8)] == [
        2.0, 3.0, 4.5, 6.75, 10.125, 15.1875, 22.78125, 34.171875
    ]


class TestFluentSender(object):
    def pytest_funcarg__sender(self, request):
        return client.FluentSender('test')

    def pytest_funcarg__msgs(self, request):
        return [
            {'message': 'test1'}, {'message': 'test2'}, {'message': 'test3'}
        ]

    def test_init(self, sender):
        assert sender.default_tag == 'test'
        assert sender.host == 'localhost'
        assert sender.port == 24224
        assert sender.timeout == 1
        assert sender._retry_time == 0
        assert isinstance(sender.packer, msgpack.Packer)

    def test_make_socket(self, sender):
{'fraction_non_alphanumeric': 0.13414634146341464, 'fraction_numerical': 0.06215578284815106, 'mean_word_length': 2.82406015037594, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3473899', 'n_tokens_mistral': 952, 'n_tokens_neox': 852, 'n_words': 231}