Exemple #1
0
 def setUp(self):
     self.app = create_app('testing')
     self.ctx = self.app.app_context()
     self.ctx.push()
     db.drop_all()  # just in case
     db.create_all()
     self.client = self.app.test_client()
Exemple #2
0
    def setUp(self):
        self.app = create_app('testing')

        # add an additional route used only in tests
        @self.app.route('/foo')
        @async
        def foo():
            1 / 0

        self.ctx = self.app.app_context()
        self.ctx.push()
        db.drop_all()  # just in case
        db.create_all()
        self.client = self.app.test_client()
Exemple #3
0
    def setUp(self):
        self.app = create_app('testing')

        # add an additional route used only in tests
        @self.app.route('/foo')
        @async
        def foo():
            1 / 0

        self.ctx = self.app.app_context()
        self.ctx.push()
        db.drop_all()  # just in case
        db.create_all()
        self.client = self.app.test_client()
def app():
    """Calls the factory and passes test_config to configure app and db
    for testing instead of using local dev configuration"""

    # Create and open temporary file, returning file object and path
    db_fd, db_path = tempfile.mkstemp()

    # Create app with test mode and db path overridden
    app = create_app({
        'TESTING': True,
        'DATABASE': db_path,
    })

    # Initialize tables and test data
    with app.app_context():
        init_db()
        get_db().executescript(_data_sql)

    yield app

    # After test is over, close and remove temp file
    os.close(db_fd)
    os.unlink(db_path)
def test_config():
    """Check app configures TESTING modes appropriately"""
    assert not create_app().testing
    assert create_app({'TESTING': True}).testing
Exemple #6
0
import os

from flack import create_app

# Create an application instance that web servers can use. We store it as
# "application" (the wsgi default) and also the much shorter and convenient
# "app".
application = app = create_app(os.environ.get('FLACK_CONFIG', 'production'))