nose tutorial documentation

ex3_test

Contents

Source code for ex3_test

"""
例題3 nose.tools を使う。
"""

from nose.tools import *

def ok_test():
[docs] """ nose.tools.ok_ : expr が True かどうかを評価します。 """ ok_(1 == 1) def eq_test():
[docs] """ nose.tools.eq_ : a と b が等しいかどうかを評価します。 """ eq_(1 + 1, 2) @raises(TypeError)
def except_test():
[docs] """ nose.tools.raises : テスト関数に期待する値が、例外の場合に使用します。 """ raise TypeError("This test passes") @timed(.1)
def time_test():
[docs] """ nose.tools.timed : テスト実行の制限時間を設定します。 このテストは失敗します。 """ import time time.sleep(.5) def ex3_setup():
[docs] pass def ex3_teardown():
[docs] pass @with_setup(setup=ex3_setup, teardown=ex3_teardown)
def ex3_test():
[docs] """ nose.tools.with_setup : テストごとに、setup/teardown を実行します。""" ok_(True) @istest
def skip(): def run_test():
[docs] """ nose.tools.nottest : 通常は実行されますが、テストしません。 ** run_test は、表示されません。** """ ok_(True)

Contents