<commit_before>from os import path, system, environ

from tg import config
from paste.deploy import loadapp
from paste.script.appinstall import SetupCommand
from webtest import TestApp

class TestController(object):
    """
    Base functional test case for the controllers.

    The pyforge application instance (``self.app``) set up in this test
    case (and descendants) has authentication disabled, so that developers can
    test the protected areas independently of the :mod:`repoze.who` plugins
    used initially. This way, authentication can be tested once and separately.

    Check pyforge.tests.functional.test_authentication for the repoze.who
    integration tests.

    This is the officially supported way to test protected areas with
    repoze.who-testutil (http://code.gustavonarea.net/repoze.who-testutil/).

    """

    application_under_test = 'main'
    test_config = environ.get('SANDBOX') and 'sandbox-test.ini' or 'test.ini'

    def setUp(self):
        """Method called by nose before running each test"""
        # Loading the application:
        conf_dir = config.here = path.abspath(
            path.dirname(__file__) + '/../..')
        wsgiapp = loadapp('config:%s#%s' % (self.test_config, self.application_under_test),
                          relative_to=conf_dir)
        self.app = TestApp(wsgiapp)
        # Setting it up:
        test_file = path.join(conf_dir, self.test_config)
        cmd = SetupCommand('setup-app')
        cmd.run([test_file])

    def tearDown(self):
        """Method called by nose after running each test"""
        pass<commit_msg>Separate setup-app from WSGI app setup in tracker tests<commit_after>from os import path, system, environ

from tg import config
from paste.deploy import loadapp
from paste.script.appinstall import SetupCommand
from webtest import TestApp


def run_app_setup():
    test_config = environ.get('SANDBOX') and 'sandbox-test.ini' or 'test.ini'
    conf_dir = config.here = path.abspath(
        path.dirname(__file__) + '/../..')
    test_file = path.join(conf_dir, test_config)
    cmd = SetupCommand('setup-app')
    cmd.run([test_file])
    return test_config, conf_dir


class TestController(object):
    """
    Base functional test case for the controllers.

    The pyforge application instance (``self.app``) set up in this test
    case (and descendants) has authentication disabled, so that developers can
    test the protected areas independently of the :mod:`repoze.who` plugins
    used initially. This way, authentication can be tested once and separately.

    Check pyforge.tests.functional.test_authentication for the repoze.who
    integration tests.

    This is the officially supported way to test protected areas with
    repoze.who-testutil (http://code.gustavonarea.net/repoze.who-testutil/).

    """

    application_under_test = 'main'

    def setUp(self):
        """Method called by nose before running each test"""
        test_config, conf_dir = run_app_setup()
        wsgiapp = loadapp('config:%s#%s' % (test_config, self.application_under_test),
                          relative_to=conf_dir)
        self.app = TestApp(wsgiapp)

    def tearDown(self):
        """Method called by nose after running each test"""
        pass

{'fraction_non_alphanumeric': 0.09227467811158799, 'fraction_numerical': 0.0, 'mean_word_length': 3.17797695262484, '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': '2878751', 'n_tokens_mistral': 939, 'n_tokens_neox': 904, 'n_words': 295}