<commit_before>import os
import shutil
import time

from nose import SkipTest
from test_utils import FastFixtureTestCase

import amo.tests
from manage import settings
from search.utils import start_sphinx, stop_sphinx, reindex


class SphinxTestCase(amo.tests.RedisTest, FastFixtureTestCase):
    """
    This test case type can setUp and tearDown the sphinx daemon.  Use this
    when testing any feature that requires sphinx.
    """

    sphinx = True
    sphinx_is_running = False

    def setUp(self):
        super(SphinxTestCase, self).setUp()

        if not SphinxTestCase.sphinx_is_running:
            if (not settings.SPHINX_SEARCHD or
                not settings.SPHINX_INDEXER):  # pragma: no cover
                raise SkipTest()

            os.environ['DJANGO_ENVIRONMENT'] = 'test'

            if os.path.exists(settings.TEST_SPHINX_CATALOG_PATH):
                shutil.rmtree(settings.TEST_SPHINX_CATALOG_PATH)
            if os.path.exists(settings.TEST_SPHINX_LOG_PATH):
                shutil.rmtree(settings.TEST_SPHINX_LOG_PATH)

            os.makedirs(settings.TEST_SPHINX_CATALOG_PATH)
            os.makedirs(settings.TEST_SPHINX_LOG_PATH)
            reindex()
            start_sphinx()
            time.sleep(1)
            SphinxTestCase.sphinx_is_running = True

    @classmethod
    def setUpClass(cls):
        # resolve multiple inheritance
        super(SphinxTestCase, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(SphinxTestCase, cls).tearDownClass()
        if SphinxTestCase.sphinx_is_running:
            stop_sphinx()
            SphinxTestCase.sphinx_is_running = False
<commit_msg>allow sphinx to import settings_local<commit_after>import os
import shutil
import time

from nose import SkipTest
from test_utils import FastFixtureTestCase

import amo.tests
import settings_local as settings
from search.utils import start_sphinx, stop_sphinx, reindex


class SphinxTestCase(amo.tests.RedisTest, FastFixtureTestCase):
    """
    This test case type can setUp and tearDown the sphinx daemon.  Use this
    when testing any feature that requires sphinx.
    """

    sphinx = True
    sphinx_is_running = False

    def setUp(self):
        super(SphinxTestCase, self).setUp()

        if not SphinxTestCase.sphinx_is_running:
            if (not settings.SPHINX_SEARCHD or
                not settings.SPHINX_INDEXER):  # pragma: no cover
                raise SkipTest()

            os.environ['DJANGO_ENVIRONMENT'] = 'test'

            if os.path.exists(settings.TEST_SPHINX_CATALOG_PATH):
                shutil.rmtree(settings.TEST_SPHINX_CATALOG_PATH)
            if os.path.exists(settings.TEST_SPHINX_LOG_PATH):
                shutil.rmtree(settings.TEST_SPHINX_LOG_PATH)

            os.makedirs(settings.TEST_SPHINX_CATALOG_PATH)
            os.makedirs(settings.TEST_SPHINX_LOG_PATH)
            reindex()
            start_sphinx()
            time.sleep(1)
            SphinxTestCase.sphinx_is_running = True

    @classmethod
    def setUpClass(cls):
        # resolve multiple inheritance
        super(SphinxTestCase, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(SphinxTestCase, cls).tearDownClass()
        if SphinxTestCase.sphinx_is_running:
            stop_sphinx()
            SphinxTestCase.sphinx_is_running = False

{'fraction_non_alphanumeric': 0.06857483601669648, 'fraction_numerical': 0.0005963029218843172, 'mean_word_length': 2.6427795874049944, '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': '4013141', 'n_tokens_mistral': 1091, 'n_tokens_neox': 1055, 'n_words': 212}