Mercurial > hg > MakeItSo
changeset 81:0d5fac58b1a8
add a template for doctests
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 08 Jan 2011 21:24:17 -0800 |
parents | 0300ed78d630 |
children | c434b83ab600 |
files | makeitso/python_package/tests/doctest.txt makeitso/python_package/tests/test.py |
diffstat | 2 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makeitso/python_package/tests/doctest.txt Sat Jan 08 21:24:17 2011 -0800 @@ -0,0 +1,10 @@ +Test ${project} +=============== + +The obligatory imports: + + >>> import ${package} + +Run some tests. This test will fail, please fix it: + + >>> assert True == False
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makeitso/python_package/tests/test.py Sat Jan 08 21:24:17 2011 -0800 @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +""" +doctest runner +""" + +import doctest +import os + +def run_tests(): + directory = os.path.dirname(os.path.abspath(__file__)) + extraglobs = {'here': directory} + tests = [ test for test in os.listdir(directory) + if test.endswith('.txt') ] + for test in tests: + doctest.testfile(test, extraglobs=extraglobs, raise_on_error=True) + +if __name__ == '__main__': + run_tests()