Skip to content

Instantly share code, notes, and snippets.

@xintron
Created November 15, 2012 11:32
Show Gist options
  • Save xintron/4078172 to your computer and use it in GitHub Desktop.
Save xintron/4078172 to your computer and use it in GitHub Desktop.
import unittest
from flask.ext.script import Manager, Server
from project import app, db
manager = Manager(app)
class Serve(Server):
def handle(self, *args, **kwargs):
db.init_app(app)
super(Serve, self).handle(*args, **kwargs)
manager.add_command('runserver', Serve())
@manager.command
def tests():
"""Run the testsuite"""
suite = unittest.TestLoader().loadTestsFromName('pbdb.tests')
unittest.TextTestRunner(verbosity=2).run(suite)
import unittest
from project import app, db
class AuthTestCase(unittest.TestCase):
def setUp(self):
self.db_name = 'testing'
app.config['MONGODB_SETTINGS']['db'] = self.db_name
app.config['TESTING'] = True
db.init_app(app)
self.app = app
self.db = db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment