示例#1
0
def app():
    app = create_app()
    app.config.update(DEBUG=True,
                      SERVER_NAME=getenv('RUNNER_IP').strip(),
                      HOST=getenv('RUNNER_IP').strip())

    return app
def sample_app():
    app = create_app()

    with app.app_context():
        db.create_all()

    return app
示例#3
0
def client():
    app = create_app('testing')
    client = app.test_client()

    with app.app_context():
        db.create_all()

    yield client
示例#4
0
    def setUp(self):
        super(TestUserModel, self).setUp()

        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()

        db.create_all()
示例#5
0
def client():
    app = create_app()
    context = app.app_context()
    context.push()

    yield app.test_client()

    context.pop()
    return app
示例#6
0
def app():
    import sys
    sys.path.append('.')

    from sample_app import create_app

    app = create_app()
    app.debug = True
    app.testing = True

    # manually add flask-debug
    from flask_debug import Debug
    Debug(app)

    return app
def app():
    import sys
    sys.path.append('.')

    from sample_app import create_app

    app = create_app()
    app.debug = True
    app.testing = True

    # manually add flask-debug
    from flask_debug import Debug
    Debug(app)

    return app
示例#8
0
def app():
    db_fd, db_path = tempfile.mkstemp()

    app = create_app({
        'TESTING': True,
        'DATABASE': db_path,
    })

    with app.app_context():
        init_db()
        get_db().executescript(_data_sql)

    yield app

    os.close(db_fd)
    os.unlink(db_path)
示例#9
0
# under normal circumstances, this script would not be necessary. the
# sample_application would have its own setup.py and be properly installed;
# however since it is not bundled in the sdist package, we need some hacks
# to make it work

import os
import sys

print(os.path.dirname(__name__))
sys.path.append(os.path.dirname(__name__))

from sample_app import create_app

# create an app instance
app = create_app()

示例#10
0
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from flask_script import Manager, Server  # NOQA
from flask_script.commands import Shell, ShowUrls  # NOQA
from flask_migrate import MigrateCommand, Migrate  # NOQA
from sample_app import create_app  # NOQA
from sample_app.database import db  # NOQA

COV = None
if os.environ.get('FLASK_COVERAGE'):
    import coverage

    COV = coverage.coverage(branch=True, include='sample/*')
    COV.start()

app = create_app(os.getenv('FLASK_CONFIG') or 'default')
manager = Manager(app)
migrate = Migrate(app, db)


def make_shell_context():
    return dict(app=app, db=db)


@manager.command
def test(coverage=False):
    """Run the unit test."""
    if coverage and not os.environ.get('FLASK_COVERAGE'):
        import sys

        os.environ['FLASK_COVERAGE'] = '1'
示例#11
0
def app():
    app = create_app()
    return app
示例#12
0
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from flask_script import Manager, Server  # NOQA
from flask_script.commands import Shell, ShowUrls  # NOQA
from flask_migrate import MigrateCommand, Migrate  # NOQA
from sample_app import create_app  # NOQA
from sample_app.database import db  # NOQA

COV = None
if os.environ.get('FLASK_COVERAGE'):
    import coverage

    COV = coverage.coverage(branch=True, include='sample/*')
    COV.start()

app = create_app(os.getenv('FLASK_CONFIG') or 'default')
manager = Manager(app)
migrate = Migrate(app, db)


def make_shell_context():
    return dict(app=app, db=db)


@manager.command
def test(coverage=False):
    """Run the unit test."""
    if coverage and not os.environ.get('FLASK_COVERAGE'):
        import sys

        os.environ['FLASK_COVERAGE'] = '1'
示例#13
0
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from flask.ext.script import Manager
from sample_app import create_app, db, models

app = create_app()
manager = Manager(app)

@manager.command
def syncdb():
    db.create_all(app=app)

@manager.shell
def make_shell_context():
    return dict(app=app, db=db, models=models)

if __name__ == '__main__':
    manager.run()
示例#14
0
import os

from sample_app import create_app

app = create_app(os.getenv('APP_SETTINGS') or 'default')

if __name__ == '__main__':
    app.run()
示例#15
0
def test_config():
    assert not create_app().testing
    assert create_app({'TESTING': True}).testing
示例#16
0
import sample_app
app = sample_app.create_app()