Ejemplo n.º 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()
Ejemplo n.º 2
0
Archivo: tests.py Proyecto: QsBBQ/flack
    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()
Ejemplo n.º 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()
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
def test_config():
    """Check app configures TESTING modes appropriately"""
    assert not create_app().testing
    assert create_app({'TESTING': True}).testing
Ejemplo n.º 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'))