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


import os
import shutil
import sys
import unittest.mock

import sshrc

import pytest


class FakeTemplater(object):

    @staticmethod
    def render(content):
        return content

    def __init__(self, name):
        self.name = name


def have_mocked(request, *mock_args, **mock_kwargs):
    if len(mock_args) > 1:
        method = unittest.mock.patch.object
    else:
        method = unittest.mock.patch

    patch = method(*mock_args, **mock_kwargs)
    mocked = patch.start()

    request.addfinalizer(patch.stop)

    return mocked


@pytest.fixture
def mock_get_content(request):
    return have_mocked(request, "sshrc.utils.get_content")


@pytest.fixture(scope="session", autouse=True)
def mock_logger(request):
    return have_mocked(request, "sshrc.utils.logger")


@pytest.fixture(autouse=True)
def mock_log_configuration(request):
    have_mocked(request, "logging.handlers.SysLogHandler")
    marker = request.node.get_marker("no_mock_log_configuration")

    if not marker:
        return have_mocked(request, "sshrc.utils.configure_logging")

<commit_msg>Fix SysLog related problem<commit_after># -*- coding: utf-8 -*-


import os
import shutil
import sys
import unittest.mock

import sshrc

import pytest


class FakeTemplater(object):

    @staticmethod
    def render(content):
        return content

    def __init__(self, name):
        self.name = name


def have_mocked(request, *mock_args, **mock_kwargs):
    if len(mock_args) > 1:
        method = unittest.mock.patch.object
    else:
        method = unittest.mock.patch

    patch = method(*mock_args, **mock_kwargs)
    mocked = patch.start()

    request.addfinalizer(patch.stop)

    return mocked


@pytest.fixture
def mock_get_content(request):
    return have_mocked(request, "sshrc.utils.get_content")


@pytest.fixture(scope="session", autouse=True)
def mock_logger(request):
    return have_mocked(request, "sshrc.utils.logger")


@pytest.fixture(autouse=True)
def mock_log_configuration(request):
    have_mocked(request, "socket.socket")  # required for SysLogHandler

    marker = request.node.get_marker("no_mock_log_configuration")

    if not marker:
        return have_mocked(request, "sshrc.utils.configure_logging")


{'fraction_non_alphanumeric': 0.10791685095090668, 'fraction_numerical': 0.0017691287041132243, 'mean_word_length': 3.8855291576673867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5478403', 'n_tokens_mistral': 762, 'n_tokens_neox': 731, 'n_words': 152}