pythonにnoseを入れてみたときのメモ
pythonでのunittestを容易に実行できるライブラリということで評判が良さげなnoseを入れたときのメモ。
インストールはeasy_installで行った。
$ easy_install nose
テストの実行はnosetestsコマンドでテスト対象のファイルやディレクトリを指定するか、テストスクリプト内から実行することもできるらしい。
とりあえず試してみる。
nose_test.py
class TestNose(object): def test_nose(self): assert 1==1 def test_func(): assert 1==1 if __name__=='__main__': import nose nose.main()
まずはファイルを指定して実行
$ nosetests nose_test.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.000s OK
- w オプションでディレクトリを指定して実行
$ nosetests -w test .. ---------------------------------------------------------------------- Ran 2 tests in 0.000s OK
テストスクリプトから実行
$ python nose_test.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.000s OK