No Description
python
flask

flasky.py 601B

12345678910111213141516171819202122
  1. import os
  2. from flask_migrate import Migrate
  3. from app import create_app, db
  4. from app.models import User, Role, Permission, Post, Follow, Comment
  5. app = create_app(os.getenv('FLASK_CONFIG') or 'default')
  6. migrate = Migrate(app, db)
  7. @app.shell_context_processor
  8. def make_shell_context():
  9. return dict(db=db, User=User, Follow=Follow, Role=Role,
  10. Permission=Permission, Post=Post, Comment=Comment)
  11. @app.cli.command()
  12. def test():
  13. """Run the unit tests."""
  14. import unittest
  15. tests = unittest.TestLoader().discover('tests')
  16. unittest.TextTestRunner(verbosity=2).run(tests)