index.txt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. =================
  2. Testing in Django
  3. =================
  4. Automated testing is an extremely useful bug-killing tool for the modern
  5. Web developer. You can use a collection of tests -- a **test suite** -- to
  6. solve, or avoid, a number of problems:
  7. * When you're writing new code, you can use tests to validate your code
  8. works as expected.
  9. * When you're refactoring or modifying old code, you can use tests to
  10. ensure your changes haven't affected your application's behavior
  11. unexpectedly.
  12. Testing a Web application is a complex task, because a Web application is made
  13. of several layers of logic -- from HTTP-level request handling, to form
  14. validation and processing, to template rendering. With Django's test-execution
  15. framework and assorted utilities, you can simulate requests, insert test data,
  16. inspect your application's output and generally verify your code is doing what
  17. it should be doing.
  18. The best part is, it's really easy.
  19. The preferred way to write tests in Django is using the :mod:`unittest` module
  20. built in to the Python standard library. This is covered in detail in the
  21. :doc:`overview` document.
  22. You can also use any *other* Python test framework; Django provides an API and
  23. tools for that kind of integration. They are described in the
  24. :ref:`other-testing-frameworks` section of :doc:`advanced`.
  25. .. toctree::
  26. :maxdepth: 1
  27. overview
  28. tools
  29. advanced