<commit_before>from nose.tools import *

from behave.log_capture import MemoryHandler

class TestLogCapture(object):
    def test_get_value_returns_all_log_records(self):
        class FakeRecord(object):
            def __init__(self, name, levelname, message):
                self.name = name
                self.levelname = levelname
                self.getMessage = lambda: message

        records = [
            ('name', 'levelname', 'message'),
            ('othername', 'otherlevelname', 'othermessage')
        ]
        expected = '\n'.join("%s %s %s" % record for record in records)

        handler = MemoryHandler()
        handler.buffer = [FakeRecord(*record) for record in records]

        eq_(handler.getvalue(), expected)<commit_msg>Fix log capture test.<commit_after>from nose.tools import *
from mock import patch

from behave.log_capture import MemoryHandler

class TestLogCapture(object):
    def test_get_value_returns_all_log_records(self):
        class FakeConfig(object):
            logging_filter = None
            logging_format = None
            logging_datefmt = None
            logging_level = None

        fake_records = [object() for x in range(0, 10)]

        handler = MemoryHandler(FakeConfig())
        handler.buffer = fake_records

        with patch.object(handler.formatter, 'format') as format:
            format.return_value = 'foo'
            expected = '\n'.join(['foo'] * len(fake_records))

            eq_(handler.getvalue(), expected)

            calls = [args[0][0] for args in format.call_args_list]
            eq_(calls, fake_records)
{'fraction_non_alphanumeric': 0.09925093632958802, 'fraction_numerical': 0.003121098626716604, 'mean_word_length': 2.484782608695652, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1427965', 'n_tokens_mistral': 434, 'n_tokens_neox': 421, 'n_words': 109}