コード例 #1
0
ファイル: __init__.py プロジェクト: rosenthalo/invenio
def iter_suites(packages=None):
    """Yield all testsuites."""
    from werkzeug.utils import import_string, find_modules
    from flask_registry import ModuleAutoDiscoveryRegistry, \
        ImportPathRegistry

    app = create_app()

    if packages is None:
        testsuite = ModuleAutoDiscoveryRegistry('testsuite', app=app)
        from invenio import testsuite as testsuite_invenio
        testsuite.register(testsuite_invenio)
    else:
        exclude = map(lambda x: x + '.testsuite',
                      app.config.get('PACKAGES_EXCLUDE', []))
        testsuite = ImportPathRegistry(initial=packages, exclude=exclude,
                                       load_modules=True)

    for package in testsuite:
        for name in find_modules(package.__name__):
            module = import_string(name)
            if not module.__name__.split('.')[-1].startswith('test_'):
                continue
            if hasattr(module, 'TEST_SUITE'):
                yield module.TEST_SUITE
            else:
                app.logger.warning(
                    "%s: No test suite defined." % module.__name__)
コード例 #2
0
def iter_suites(packages=None):
    """Yield all testsuites."""
    from werkzeug.utils import import_string, find_modules
    from flask_registry import ModuleAutoDiscoveryRegistry, \
        ImportPathRegistry

    app = create_app()

    if packages is None:
        testsuite = ModuleAutoDiscoveryRegistry('testsuite', app=app)
        from invenio import testsuite as testsuite_invenio
        testsuite.register(testsuite_invenio)
    else:
        exclude = map(lambda x: x + '.testsuite',
                      app.config.get('PACKAGES_EXCLUDE', []))
        testsuite = ImportPathRegistry(initial=packages,
                                       exclude=exclude,
                                       load_modules=True)

    for package in testsuite:
        for name in find_modules(package.__name__):
            module = import_string(name)
            if not module.__name__.split('.')[-1].startswith('test_'):
                continue
            if hasattr(module, 'TEST_SUITE'):
                yield module.TEST_SUITE
            else:
                app.logger.warning("%s: No test suite defined." %
                                   module.__name__)
コード例 #3
0
ファイル: celery.py プロジェクト: movermeyer/flask-appfactory
def load_tasks(app):
    """Load Celery tasks from installed packages.

    .. versionadded:: v0.2.0
    """
    app.extensions['registry']['tasks'] = ModuleAutoDiscoveryRegistry(
            module_name='tasks', app=app)
コード例 #4
0
    def test_registration(self):
        Registry(app=self.app)

        self.app.extensions['registry']['pathns'] = \
            ImportPathRegistry(initial=['flask_registry.*'])

        self.assertEqual(4, len(self.app.extensions['registry']['pathns']))

        self.app.extensions['registry']['myns'] = \
            ModuleAutoDiscoveryRegistry('appdiscovery',
                                        app=self.app,
                                        registry_namespace='pathns')

        assert len(self.app.extensions['registry']['myns']) == 1
        from flask_registry.registries import appdiscovery
        assert self.app.extensions['registry']['myns'][0] == appdiscovery
コード例 #5
0
bibformat = lazy_import('invenio.modules.formatter')
bibformat_engine = lazy_import('invenio.modules.formatter.engine')
bibformat_utils = lazy_import('invenio.modules.formatter.utils')
bibformat_config = lazy_import('invenio.modules.formatter.config')
gettext_set_language = lazy_import('invenio.base.i18n:gettext_set_language')

TEST_PACKAGES = [
    'invenio.modules.formatter.testsuite.overlay',
    'invenio.modules.formatter.testsuite',
]

test_registry = RegistryProxy('test_registry',
                              ImportPathRegistry,
                              initial=TEST_PACKAGES)

output_formats_directories_registry = lambda: ModuleAutoDiscoveryRegistry(
    'output_formats', registry_namespace=test_registry, silent=True)


class OutputFormatTest(InvenioTestCase):
    """ bibformat - tests on output formats"""
    def setUp(self):
        self.app.extensions['registry']['output_formats_directories'] = \
            output_formats_directories_registry()
        from invenio.modules.formatter.registry import output_formats as ofs
        ofs.expunge()

    def tearDown(self):
        from invenio.modules.formatter.registry import output_formats as ofs
        ofs.expunge()
        del self.app.extensions['registry']['output_formats_directories']