<commit_before>from __future__ import unicode_literals, division, absolute_import
import logging
import os
import sys
import yaml
from contextlib import contextmanager

import pytest

import flexget.logger
from flexget.manager import Manager
from flexget.plugin import load_plugins
from flexget.task import Task, TaskAbort

log = logging.getLogger('tests')


@pytest.fixture(scope='session', autouse=True)
def setup_once():
    flexget.logger.initialize(True)
    #setup_logging_level()
    # VCR.py mocked functions not handle ssl verification well. Older versions of urllib3 don't have this
    # if VCR_RECORD_MODE != 'off':
    #     try:
    #         from requests.packages.urllib3.exceptions import SecurityWarning
    #         warnings.simplefilter('ignore', SecurityWarning)
    #     except ImportError:
    #         pass
    load_plugins()


# --- These are the public fixtures tests can ask for ---

@pytest.fixture(scope='class')
def config(request):
    """
    If used inside a test class, uses the `config` class attribute of the class.
    This is used by `manager` fixture, and can be parametrized.
    """
    return request.cls.config


@pytest.fixture()
def manager(request, config):
    """
    Create a :class:`MockManager` for this test based on `config` argument.
    """
    mockmanager = MockManager(config, request.cls.__name__)

    def fin():
        mockmanager.shutdown()
        mockmanager.__del__()

    request.addfinalizer(fin)
    return mockmanager


@pytest.fixture()
def execute_task(manager):
    """<commit_msg>Clean up manager fixture a bit<commit_after>from __future__ import unicode_literals, division, absolute_import
import logging
import os
import sys
import yaml
from contextlib import contextmanager

import pytest

import flexget.logger
from flexget.manager import Manager
from flexget.plugin import load_plugins
from flexget.task import Task, TaskAbort

log = logging.getLogger('tests')


@pytest.fixture(scope='session', autouse=True)
def setup_once():
    flexget.logger.initialize(True)
    #setup_logging_level()
    # VCR.py mocked functions not handle ssl verification well. Older versions of urllib3 don't have this
    # if VCR_RECORD_MODE != 'off':
    #     try:
    #         from requests.packages.urllib3.exceptions import SecurityWarning
    #         warnings.simplefilter('ignore', SecurityWarning)
    #     except ImportError:
    #         pass
    load_plugins()


# --- These are the public fixtures tests can ask for ---

@pytest.fixture(scope='class')
def config(request):
    """
    If used inside a test class, uses the `config` class attribute of the class.
    This is used by `manager` fixture, and can be parametrized.
    """
    return request.cls.config


@pytest.yield_fixture()
def manager(request, config):
    """
    Create a :class:`MockManager` for this test based on `config` argument.
    """
    mockmanager = MockManager(config, request.cls.__name__)
    yield mockmanager
    mockmanager.shutdown()
    mockmanager.__del__()


@pytest.fixture()
def execute_task(manager):
    """
{'fraction_non_alphanumeric': 0.09223773952582007, 'fraction_numerical': 0.0012991230919129587, 'mean_word_length': 3.6246246246246248, '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': '6566910', 'n_tokens_mistral': 896, 'n_tokens_neox': 884, 'n_words': 276}