Exemplo n.º 1
0
def test_app(test, config_file=None, argv=None, **params):
    '''Return an application for testing. Override if needed.
    '''
    kwargs = test.config_params.copy()
    kwargs.update(params)
    if 'SECRET_KEY' not in kwargs:
        kwargs['SECRET_KEY'] = generate_secret()
    config_file = config_file or test.config_file
    if argv is None:
        argv = []
    if '--log-level' not in argv:
        argv.append('--log-level')
        levels = test.cfg.loglevel if hasattr(test, 'cfg') else ['none']
        argv.extend(levels)
    app = lux.App(config_file, argv=argv, **kwargs).setup()
    #
    # Data mapper
    app.stdout = StringIO()
    app.stderr = StringIO()
    return app
Exemplo n.º 2
0
def test_app(test, config_file=None, argv=None, **params):
    '''Return an application for testing. Override if needed.
    '''
    kwargs = test.config_params.copy()
    kwargs.update(params)
    if 'SECRET_KEY' not in kwargs:
        kwargs['SECRET_KEY'] = generate_secret()
    config_file = config_file or test.config_file
    if argv is None:
        argv = []
    if '--log-level' not in argv:
        argv.append('--log-level')
        levels = test.cfg.loglevel if hasattr(test, 'cfg') else ['none']
        argv.extend(levels)
    app = lux.App(config_file, argv=argv, **kwargs).setup()
    #
    # Data mapper
    app.stdout = StringIO()
    app.stderr = StringIO()
    return app
Exemplo n.º 3
0
def test_app(test, config_file=None, config_params=True, argv=None, **params):
    """Return an application for testing. Override if needed.
    """
    if config_params:
        kwargs = test.config_params.copy()
        kwargs.update(params)
    else:
        kwargs = params
    config_file = config_file or test.config_file
    if argv is None:
        argv = []
    if '--log-level' not in argv:
        argv.append('--log-level')
        levels = test.cfg.log_level if hasattr(test, 'cfg') else ['none']
        argv.extend(levels)
    app = App(config_file, argv=argv, cfg=test.cfg, **kwargs).setup(
        on_config=test.app_test_providers)
    if app.config['SECRET_KEY'] == 'secret-key':
        app.config['SECRET_KEY'] = generate_secret()
    app.stdout = StringIO()
    app.stderr = StringIO()
    return app
Exemplo n.º 4
0
def test_app(test, config_file=None, config_params=True, argv=None, **params):
    """Return an application for testing. Override if needed.
    """
    if config_params:
        kwargs = test.config_params.copy()
        kwargs.update(params)
    else:
        kwargs = params
    config_file = config_file or test.config_file
    if argv is None:
        argv = []
    if '--log-level' not in argv:
        argv.append('--log-level')
        levels = test.cfg.log_level if hasattr(test, 'cfg') else ['none']
        argv.extend(levels)
    app = App(config_file, argv=argv, cfg=test.cfg,
              **kwargs).setup(on_config=test.app_test_providers)
    if app.config['SECRET_KEY'] == 'secret-key':
        app.config['SECRET_KEY'] = generate_secret()
    app.stdout = StringIO()
    app.stderr = StringIO()
    return app