<commit_before>"""
:mod:`zsl.testing.zsl`
----------------------
This module allows for unit testing with a Zsl instance. Use 
:class:`.ZslTestCase` as a mixin to create a predefined Zsl instance to be used
while testing. Refer to unit testing section :ref:`unit-testing-zsl-instance`
for an example.
"""
from __future__ import absolute_import
from __future__ import unicode_literals
from builtins import *

from collections import namedtuple

import logging
from functools import partial

from zsl import Zsl
from zsl.application.service_application import set_profile
from zsl.configuration import InvalidConfigurationException

ZslTestConfiguration = namedtuple('ZslTestConfiguration',
                                  ['app_name', 'version', 'container',
                                   'profile', 'config_object'])
ZslTestConfiguration.__new__ = partial(ZslTestConfiguration.__new__,
                                       config_object=None,
                                       version=None,
                                       profile=None)


class ZslTestCase(object):
    ZSL_TEST_CONFIGURATION = None  # type: ZslTestConfiguration

    @classmethod
    def setUpClass(cls):
        if cls.ZSL_TEST_CONFIGURATION is None:
            raise InvalidConfigurationException("Please give a test container "
                                                "specification via 'container' "
                                                "class variable.")

        config: ZslTestConfiguration = cls.ZSL_TEST_CONFIGURATION
        if config.profile:
            set_profile(config.profile)
        app = Zsl(config.app_name + "-test",
                  version=config.version,
                  modules=config.container.modules(),
                  config_object=config.config_object)
        logging.getLogger(config.app_name).debug(
            "ZSL test app created {0}.".format(app))

        super(ZslTestCase, cls).setUpClass()
<commit_msg>Fix unit tests for Py2.7<commit_after>"""
:mod:`zsl.testing.zsl`
----------------------
This module allows for unit testing with a Zsl instance. Use 
:class:`.ZslTestCase` as a mixin to create a predefined Zsl instance to be used
while testing. Refer to unit testing section :ref:`unit-testing-zsl-instance`
for an example.
"""
from __future__ import absolute_import
from __future__ import unicode_literals
from builtins import *

from collections import namedtuple

import logging
from functools import partial

from zsl import Zsl
from zsl.application.service_application import set_profile
from zsl.configuration import InvalidConfigurationException

ZslTestConfiguration = namedtuple('ZslTestConfiguration',
                                  ['app_name', 'version', 'container',
                                   'profile', 'config_object'])
ZslTestConfiguration.__new__ = partial(ZslTestConfiguration.__new__,
                                       config_object=None,
                                       version=None,
                                       profile=None)


class ZslTestCase(object):
    ZSL_TEST_CONFIGURATION = None  # type: ZslTestConfiguration

    @classmethod
    def setUpClass(cls):
        if cls.ZSL_TEST_CONFIGURATION is None:
            raise InvalidConfigurationException("Please give a test container "
                                                "specification via 'container' "
                                                "class variable.")

        config = cls.ZSL_TEST_CONFIGURATION  # type: ZslTestConfiguration
        if config.profile:
            set_profile(config.profile)
        app = Zsl(config.app_name + "-test",
                  version=config.version,
                  modules=config.container.modules(),
                  config_object=config.config_object)
        logging.getLogger(config.app_name).debug(
            "ZSL test app created {0}.".format(app))

        super(ZslTestCase, cls).setUpClass()

{'fraction_non_alphanumeric': 0.08229616459232919, 'fraction_numerical': 0.001016002032004064, 'mean_word_length': 2.0837901331245106, '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': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6230435', 'n_tokens_mistral': 959, 'n_tokens_neox': 938, 'n_words': 257}