<commit_before>import os
import sys

import pytest

from nikola.utils import LocaleBorg

from ..conftest import ensure_chdir  # NOQA - autouse fixture


@pytest.fixture(scope="session")
def other_locale():
    return os.environ.get('NIKOLA_LOCALE_OTHER', 'pl')


@pytest.fixture(scope="module")
def output_dir(target_dir):
    return os.path.join(target_dir, "output")


@pytest.fixture(scope="module")
def target_dir(tmpdir_factory):
    tdir = tmpdir_factory.mktemp('integration').join('target')
    yield str(tdir)


@pytest.fixture(scope="module", autouse=True)
def remove_conf_module():
    """
    Remove the module `conf` from `sys.modules` after loading the config.

    Fixes issue #438
    """
    try:
        yield
    finally:
        try:
            del sys.modules['conf']
        except KeyError:
            pass


@pytest.fixture(scope="module", autouse=True)
def localeborg_setup(default_locale):
    """
    Reset the LocaleBorg before and after every test.
    """
    LocaleBorg.reset()
    LocaleBorg.initialize({}, default_locale)
    try:
        yield
    finally:
        LocaleBorg.reset()
<commit_msg>This should already be automatically applied.<commit_after>import os
import sys

import pytest

from nikola.utils import LocaleBorg


@pytest.fixture(scope="session")
def other_locale():
    return os.environ.get('NIKOLA_LOCALE_OTHER', 'pl')


@pytest.fixture(scope="module")
def output_dir(target_dir):
    return os.path.join(target_dir, "output")


@pytest.fixture(scope="module")
def target_dir(tmpdir_factory):
    tdir = tmpdir_factory.mktemp('integration').join('target')
    yield str(tdir)


@pytest.fixture(scope="module", autouse=True)
def remove_conf_module():
    """
    Remove the module `conf` from `sys.modules` after loading the config.

    Fixes issue #438
    """
    try:
        yield
    finally:
        try:
            del sys.modules['conf']
        except KeyError:
            pass


@pytest.fixture(scope="module", autouse=True)
def localeborg_setup(default_locale):
    """
    Reset the LocaleBorg before and after every test.
    """
    LocaleBorg.reset()
    LocaleBorg.initialize({}, default_locale)
    try:
        yield
    finally:
        LocaleBorg.reset()

{'fraction_non_alphanumeric': 0.11878081577767817, 'fraction_numerical': 0.002689376961004034, 'mean_word_length': 3.4023668639053253, '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': '218749', 'n_tokens_mistral': 741, 'n_tokens_neox': 729, 'n_words': 160}