Skip to content

Instantly share code, notes, and snippets.

@jeanphix
Created October 3, 2012 13:57
Show Gist options
  • Save jeanphix/3827051 to your computer and use it in GitHub Desktop.
Save jeanphix/3827051 to your computer and use it in GitHub Desktop.
Flask-Script test command
import unittest
@manager.command
@manager.option('-p', '--path', help='Path to specific test(s).')
def test(path=None, verbosity=1):
"""Runs tests.
"""
loader = unittest.TestLoader()
if path is None:
suite = loader.discover('.', pattern='*.py')
else:
suite = loader.loadTestsFromName(path)
unittest.TextTestRunner(verbosity=int(verbosity)).run(suite)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment