#!/usr/bin/env python3 # # See https://stackoverflow.com/questions/67538056/flask-script-from-flask-compat-import-text-type-modulenotfounderror-no-module # Fix line 15 in venv/lib/python3.8/site-packages/flask_script/__init__.py # from flask_script import Manager, Shell import os from twofa import create_app, db from twofa.models import User app = create_app(os.getenv("FLASK_CONFIG") or "default") manager = Manager(app) def make_shell_context(): return dict(app=app, db=db, User=User) manager.add_command("shell", Shell(make_context=make_shell_context)) @manager.command def test(): """Run the unit tests.""" import sys, unittest tests = unittest.TestLoader().discover("tests") result = unittest.TextTestRunner(verbosity=2).run(tests)
#!/usr/bin/env python from flask.ext.script import Manager, Shell from flask.ext.migrate import Migrate, MigrateCommand import os from twofa import create_app, db from twofa.models import User 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, User=User) manager.add_command('shell', Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) @manager.command def test(): """Run the unit tests.""" import sys, unittest tests = unittest.TestLoader().discover('tests') result = unittest.TextTestRunner(verbosity=2).run(tests) if not result.wasSuccessful(): sys.exit(1)
def setUp(self): self.app = create_app("testing") self.client = self.app.test_client() db.create_all()
def setUp(self): self.app = create_app("testing") self.user = User("*****@*****.**", "fakepassword", "Alice", 33, 600112233, 123) db.create_all()
def setUp(self): self.app = create_app('testing') db.create_all()
def setUp(self): self.app = create_app('testing') self.client = self.app.test_client() self.user = User('*****@*****.**', 'fakepassword', 'test', 33, '611223344', 1234) db.create_all()
def setUp(self): self.app = create_app("testing") self.client = self.app.test_client() self.user = User("*****@*****.**", "fakepassword", "test", 33, "611223344", 1234) db.create_all()
def setUp(self): self.app = create_app('testing') self.user = User('*****@*****.**', 'fakepassword', 'Alice', 33, 600112233, 123) db.create_all()
#!/usr/bin/env python from flask.ext.script import Manager, Shell from flask.ext.migrate import Migrate, MigrateCommand import os from twofa import create_app, db from twofa.models import User 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, User=User) manager.add_command('shell', Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) @manager.command def test(): """Run the unit tests.""" import unittest tests = unittest.TestLoader().discover('tests') unittest.TextTestRunner(verbosity=2).run(tests) if __name__ == "__main__": manager.run()