-
Shorthand for assert. Saves 3 whole characters!
-
Shorthand for ‘assert a == b, “%r != %r” % (a, b)
-
Wraps a test decorator so as to properly replicate metadata of the decorated function, including nose’s additional stuff (namely, setup and teardown).
-
Test must raise one of expected exceptions to pass.
Example use:
If you want to test many assertions about exceptions in a single test, you may want to use assert_raises instead.
-
Call pdb.set_trace in the calling frame, first restoring sys.stdout to the real output stream. Note that sys.stdout is NOT reset to whatever it was before the call once pdb is done!
-
Test must finish within specified time limit to pass.
Example use:
-
Decorator to add setup and/or teardown methods to a test function:
Note that with_setup is useful only for test functions, not for test methods or inside of TestCase subclasses.
-
Decorator to mark a function or method as a test
-
Decorator to mark a function or method as not a test
nose.tools 提供一些方法可以方便我们写测试用例,让测试更简单
nose.tools.
ok_
(expr, msg=None)¶
nose.tools.
eq_
(
a,
b,
msg=None
)
nose.tools.
make_decorator
(
func
)
nose.tools.
raises
(
*exceptions
)
nose.tools.
set_trace
(
)
nose.tools.
timed
(
limit
)
nose.tools.
with_setup
(
setup=None,
teardown=None
)
nose.tools.
istest
(
func
)
nose.tools.
nottest
(
func
)