<commit_before>import unittest
from pyramid.config import Configurator
from pyramid.testing import DummyRequest
from pyramid import testing


from substanced.db import root_factory

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings, root_factory=root_factory)
    return config.make_wsgi_app()


class FunctionalTests(unittest.TestCase):

    def setUp(self):
        import tempfile
        import os.path
        self.tmpdir = tempfile.mkdtemp()

        dbpath = os.path.join( self.tmpdir, 'test.db')
        uri = 'file://' + dbpath
        settings = {'zodbconn.uri': uri,
                    'substanced.secret': 'sosecret',
                    'substanced.initial_login': 'admin',
                    'substanced.initial_password': '<PASSWORD>',
                    'pyramid.includes': [
            'pyramid_tm',
            'substanced',
            'dace',
        ]}

        app = main({}, **settings)
        self.db = app.registry._zodb_databases['']
        self.request = request = DummyRequest()
        self.config = testing.setUp(registry=app.registry, request=request)
        self.registry = self.config.registry
        self.app = root_factory(request)
        request.root = self.app
        self.users = self.app['principals']['users']
        self.app['principals'].add_user('alice', password='<PASSWORD>', email='<EMAIL>')
        request.user = self.users['admin']
#        from webtest import TestApp
#        self.testapp = TestApp(app)

    def tearDown(self):
        import shutil
        testing.tearDown()
        self.db.close()
        shutil.rmtree(self.tmpdir)<commit_msg>isolate tests<commit_after>import unittest
from pyramid.config import Configurator
from pyramid.testing import DummyRequest
from pyramid import testing


from substanced.db import root_factory

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings, root_factory=root_factory)
    return config.make_wsgi_app()


class FunctionalTests(unittest.TestCase):

    def setUp(self):
        import tempfile
        import os.path
        self.tmpdir = tempfile.mkdtemp()

        dbpath = os.path.join( self.tmpdir, 'test.db')
        uri = 'file://' + dbpath
        settings = {'zodbconn.uri': uri,
                    'substanced.secret': 'sosecret',
                    'substanced.initial_login': 'admin',
                    'substanced.initial_password': '<PASSWORD>',
                    'pyramid.includes': [
            'pyramid_tm',
            'substanced',
            'dace',
        ]}

        app = main({}, **settings)
        self.db = app.registry._zodb_databases['']
        self.request = request = DummyRequest()
        self.config = testing.setUp(registry=app.registry, request=request)
        self.registry = self.config.registry
        self.app = root_factory(request)
        request.root = self.app
        self.users = self.app['principals']['users']
        self.app['principals'].add_user('alice', password='<PASSWORD>', email='<EMAIL>')
        request.user = self.users['admin']
        from dace.processinstance import event
        event.callbacks = {}

    def tearDown(self):
        import shutil
        testing.tearDown()
        self.db.close()
        shutil.rmtree(self.tmpdir)
{'fraction_non_alphanumeric': 0.11973067915690866, 'fraction_numerical': 0.0, 'mean_word_length': 2.4204204204204203, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2796587', 'n_tokens_mistral': 1017, 'n_tokens_neox': 975, 'n_words': 199}