Skip to content

Instantly share code, notes, and snippets.

@yinyin
Created July 8, 2012 04:39
Show Gist options
  • Save yinyin/3069379 to your computer and use it in GitHub Desktop.
Save yinyin/3069379 to your computer and use it in GitHub Desktop.
Modified unit2.py for automatic test discovery
#! /usr/bin/env python
# based on the unit2.py from unittest2
# {{{ automatically attach options for discover
import sys
if (1 == len(sys.argv)) or ( (2 == len(sys.argv)) and (sys.argv[1] in ("-v", "--verbose",)) ):
extra_arg = None
if 2 == len(sys.argv):
extra_arg = sys.argv.pop()
sys.argv.extend(("discover", "-s", "test/", "-p", "test_*.py",))
if extra_arg is not None:
sys.argv.append(extra_arg)
# }}} automatically attach options for discover
__unittest = True
from unittest2.main import main_
main_()
# vim: ts=4 sw=4 ai nowrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment