Nose will automatically run any function it finds in the project starting with test_*
. So, for example, if there is a function called:
"""
test_server_setup.py
sets up a pristine database to use for testing.
DO NOT RUN ON PROD
"""
def test_server_init():
drop_all_tables()
...then nose will run it when you run the command nosetests
from the root of the project. Is my only option to rename this function, or is there another way I can change the file so that nose ignores it?
nottest decorator is exactly what you need:
nose.tools.nottest(func)
Decorator to mark a function or method as not a test
from nose.tools import nottest
@nottest
def test_server_init():
drop_all_tables()
To exclude a file or a directory from being picked up by the nose test discovery, see: