import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand

from config import basedir
from app import create_app, db
from app.models import User, Dictionary

app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")

migrate = Migrate(app, db)
manager = Manager(app)


def make_shell_context():
    return dict(app=app, db=db, User=User, Dictionary=Dictionary)

manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)

cov = coverage.coverage(branch=True, include="app/*")


@manager.command
def test(coverage=False):
    """ Run the unit tests. """
    if coverage:
        cov.start()

    import unittest
    tests = unittest.TestLoader().discover("tests")
    unittest.TextTestRunner(verbosity=2).run(tests)

    if coverage:
        cov.stop()
        cov.save()
        print("Coverage Summary:")
        cov.report()
        cov_dir = os.path.join(basedir, "tmp/coverage")
        cov.html_report(directory=cov_dir)
        print("HTML version: %s/index.html" % cov_dir)
        cov.erase()


if __name__ == "__main__":
    manager.run()
import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand

from config import basedir
from app import create_app, db
from app.models import User, Dictionary, Word

app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")

migrate = Migrate(app, db)
manager = Manager(app)


def make_shell_context():
    return dict(app=app, db=db, User=User, Dictionary=Dictionary, Word=Word)

manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)

cov = coverage.coverage(branch=True, include="app/*")


@manager.command
def test(coverage=False):
    """ Run the unit tests. """
    if coverage:
        cov.start()

    import unittest
    tests = unittest.TestLoader().discover("tests")
    unittest.TextTestRunner(verbosity=2).run(tests)

    if coverage:
        cov.stop()
        cov.save()
        print("Coverage Summary:")
        cov.report()
        cov_dir = os.path.join(basedir, "tmp/coverage")
        cov.html_report(directory=cov_dir)
        print("HTML version: %s/index.html" % cov_dir)
        cov.erase()


if __name__ == "__main__":
    manager.run()
Add Word model to shell context
Add Word model to shell context

  import os
  import coverage
  from flask_script import Manager, Shell
  from flask_migrate import Migrate, MigrateCommand
  
  from config import basedir
  from app import create_app, db
- from app.models import User, Dictionary
+ from app.models import User, Dictionary, Word
  
  app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
  
  migrate = Migrate(app, db)
  manager = Manager(app)
  
  
  def make_shell_context():
-     return dict(app=app, db=db, User=User, Dictionary=Dictionary)
+     return dict(app=app, db=db, User=User, Dictionary=Dictionary, Word=Word)
  
  manager.add_command("shell", Shell(make_context=make_shell_context))
  manager.add_command("db", MigrateCommand)
  
  cov = coverage.coverage(branch=True, include="app/*")
  
  
  @manager.command
  def test(coverage=False):
      """ Run the unit tests. """
      if coverage:
          cov.start()
  
      import unittest
      tests = unittest.TestLoader().discover("tests")
      unittest.TextTestRunner(verbosity=2).run(tests)
  
      if coverage:
          cov.stop()
          cov.save()
          print("Coverage Summary:")
          cov.report()
          cov_dir = os.path.join(basedir, "tmp/coverage")
          cov.html_report(directory=cov_dir)
          print("HTML version: %s/index.html" % cov_dir)
          cov.erase()
  
  
  if __name__ == "__main__":
      manager.run()
Add Word model to shell context
## Code Before:
import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand

from config import basedir
from app import create_app, db
from app.models import User, Dictionary

app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")

migrate = Migrate(app, db)
manager = Manager(app)


def make_shell_context():
    return dict(app=app, db=db, User=User, Dictionary=Dictionary)

manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)

cov = coverage.coverage(branch=True, include="app/*")


@manager.command
def test(coverage=False):
    """ Run the unit tests. """
    if coverage:
        cov.start()

    import unittest
    tests = unittest.TestLoader().discover("tests")
    unittest.TextTestRunner(verbosity=2).run(tests)

    if coverage:
        cov.stop()
        cov.save()
        print("Coverage Summary:")
        cov.report()
        cov_dir = os.path.join(basedir, "tmp/coverage")
        cov.html_report(directory=cov_dir)
        print("HTML version: %s/index.html" % cov_dir)
        cov.erase()


if __name__ == "__main__":
    manager.run()
## Instruction:
Add Word model to shell context
## Code After:
import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand

from config import basedir
from app import create_app, db
from app.models import User, Dictionary, Word

app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")

migrate = Migrate(app, db)
manager = Manager(app)


def make_shell_context():
    return dict(app=app, db=db, User=User, Dictionary=Dictionary, Word=Word)

manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)

cov = coverage.coverage(branch=True, include="app/*")


@manager.command
def test(coverage=False):
    """ Run the unit tests. """
    if coverage:
        cov.start()

    import unittest
    tests = unittest.TestLoader().discover("tests")
    unittest.TextTestRunner(verbosity=2).run(tests)

    if coverage:
        cov.stop()
        cov.save()
        print("Coverage Summary:")
        cov.report()
        cov_dir = os.path.join(basedir, "tmp/coverage")
        cov.html_report(directory=cov_dir)
        print("HTML version: %s/index.html" % cov_dir)
        cov.erase()


if __name__ == "__main__":
    manager.run()