noseでテスト
nosetestsは、proveみたいなものです。plugin機構があって拡張できるようになっているので、prove以上に色んな事ができます。
使い方は、いかのとおり。
インストール
pip install nose pip install rednose
テストの色づけ
.noserc
[nosetests] verbosity=3 nocapture=1 rednose=1
Makefile
Makefileに以下を定義
TESTS = \ simple_package_template \ tests TEST_OPTIONS = \ -v \ --with-doctest default: all all: @echo "Nothing to do" test: @(nosetests $(TEST_OPTIONS) $(TESTS)) testxml: @(nosetests $(TEST_OPTIONS) --with-xunit $(TESTS) ) profile: @(nosetests --with-profile --profile-stats-file=nose.prof $(TESTS)) @(python -c "import hotshot.stats ; stats = hotshot.stats.load('nose.prof') ; stats.sort_stats('time', 'calls') ; stats.print_stats(20)") coverage: @(nosetests --with-coverage $(TESTS))
テスト
make test
などなど。
CI: Hudsonとの連携
Hudsonに、nosetests --with-xunitの結果をくわせてる
http://www.rhonabwy.com/wp/2009/11/04/setting-up-a-python-ci-server-with-hudson/
TODO
# doctestのoptionは、後で調べる。
[nosetests] with-doctest=1 doctest-extension=.rst doctest-fixtures=_fixtures