/doc/plugins.rst

https://bitbucket.org/jpellerin/nose/ · ReStructuredText · 70 lines · 50 code · 20 blank · 0 comment · 0 complexity · fb5484048090a5760393966c93c481f3 MD5 · raw file

  1. Extending and customizing nose with plugins
  2. ===========================================
  3. nose has plugin hooks for loading, running, watching and reporting on tests and
  4. test runs. If you don't like the default collection scheme, or it doesn't suit
  5. the layout of your project, or you need reports in a format different from the
  6. unittest standard, or you need to collect some additional information about
  7. tests (like code coverage or profiling data), you can write a plugin to do so.
  8. See the section on `writing plugins`_ for more.
  9. nose also comes with a number of built-in plugins, such as:
  10. * Output capture
  11. Unless called with the ``-s`` (``--nocapture``) switch, nose will capture
  12. stdout during each test run, and print the captured output only for tests
  13. that fail or have errors. The captured output is printed immediately
  14. following the error or failure output for the test. (Note that output in
  15. teardown methods is captured, but can't be output with failing tests, because
  16. teardown has not yet run at the time of the failure.)
  17. * Assert introspection
  18. When run with the ``-d`` (``--detailed-errors``) switch, nose will try to
  19. output additional information about the assert expression that failed with
  20. each failing test. Currently, this means that names in the assert expression
  21. will be expanded into any values found for them in the locals or globals in
  22. the frame in which the expression executed.
  23. In other words, if you have a test like::
  24. def test_integers():
  25. a = 2
  26. assert a == 4, "assert 2 is 4"
  27. You will get output like::
  28. File "/path/to/file.py", line XX, in test_integers:
  29. assert a == 4, "assert 2 is 4"
  30. AssertionError: assert 2 is 4
  31. >> assert 2 == 4, "assert 2 is 4"
  32. Please note that dotted names are not expanded, and callables are not called
  33. in the expansion.
  34. See below for the rest of the built-in plugins.
  35. Using Builtin plugins
  36. ---------------------
  37. See :doc:`plugins/builtin`
  38. Writing plugins
  39. ---------------
  40. .. toctree ::
  41. :maxdepth: 2
  42. plugins/writing
  43. plugins/interface
  44. plugins/errorclasses
  45. plugins/documenting
  46. Testing plugins
  47. ---------------
  48. .. toctree ::
  49. :maxdepth: 2
  50. plugins/testing