pythonのテストツール「nose」を使ってみる
http://somethingaboutorange.com/mrl/projects/nose/1.0.0/
インストールする
easy_install一発
[02-19 17:36:18 suzuki@hoge /Users/suzuki/projects/gaeprj/lib]
sudo easy_install nose (svn)-[SZK:17]
Password:
Searching for nose
Best match: nose 1.0.0
Processing nose-1.0.0-py2.6.egg
nose 1.0.0 is already the active version in easy-install.pth
Installing nosetests-2.6 script to /usr/local/bin
Installing nosetests script to /usr/local/binUsing /Library/Python/2.6/site-packages/nose-1.0.0-py2.6.egg
Processing dependencies for nose
Finished processing dependencies for nose
あと、rednoseもいれた。
テスト書いてみた
よくわからないけど、テスト書いてみた
# -*- coding: utf-8 -*- from nose.tools import * def add_five(num): return num + 5 class TestHoge(): def test_fuga3(self): eq_(3 + 5, add_five(3)) def test_fuga4(self): eq_(4 + 5, add_five(4)) def test_fuga5(self): eq_(5 + 5, add_five(5)) def test_fuga6(self): eq_(6 + 5, add_five(6))
テスト実行してみた
02-19 18:04:06 suzuki@hoge /Users/suzuki/projects/gaeprj/lib]
nosetests (svn)-[SZK:17]
test_hatebu.TestHoge.test_fuga3 ... passed
test_hatebu.TestHoge.test_fuga4 ... passed
test_hatebu.TestHoge.test_fuga5 ... passed
test_hatebu.TestHoge.test_fuga6 ... passed
- -
4 tests run in 0.0 seconds (4 tests passed)
うーん、結局テストの書き方がよくわからん。