def setUp(self): self.app = application_factory('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all()
import os from app import application_factory, db from app.models import * from flask.ext.script import Manager, Shell app = application_factory(os.getenv('FLASK_CONFIG') or 'default') manager = Manager(app) ## Working with shell, import this commannt. def make_shell_context(): return dict(app=app, db=db, User=User, Category=Category, Post=Post, Images=Images) manager.add_command("shell", Shell(make_context=make_shell_context)) @manager.command def test(): """Run the unit tests.""" import unittest tests = unittest.TestLoader().discover('tests') unittest.TextTestRunner(verbosity=2).run(tests) ##