public
Last active

Custom test runner script

  • Download Gist
runtests.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#!/usr/bin/env python
#
"""
runtests.py: Runs the project tests.
 
Usage:
python runtests.py [nose options] [tests]
 
'tests' may be:
* package or module
 
python runtests.py tests/user
python runtests.py tests/my_stuff.py
 
* specific test case:
 
python runtests.py tests/my_stuff.py:ToIntTestCase
 
* test case method:
 
python runtests.py tests/my_stuff.py:ToIntTestCase.test_something
"""
import os
import sys
 
import nose
import rednose
 
 
# add lib to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib'))
 
 
def get_env():
env = {
"NOSE_VERBOSE": os.getenv('NOSE_VERBOSE', 2),
"NOSE_REDNOSE": 1
}
 
return env
 
 
def get_plugins():
plugins = [rednose.RedNose()]
 
return plugins
 
 
if __name__ == "__main__":
nose.main(env=get_env(), plugins=get_plugins(), defaultTest="tests")

This script will live next to a python package named "tests" containing all your test suite.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.