2
0

index.txt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  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 preferred way to write tests in Django is using the :mod:`unittest` module
  19. built-in to the Python standard library. This is covered in detail in the
  20. :doc:`overview` document.
  21. You can also use any *other* Python test framework; Django provides an API and
  22. tools for that kind of integration. They are described in the
  23. :ref:`other-testing-frameworks` section of :doc:`advanced`.
  24. .. toctree::
  25. :maxdepth: 1
  26. overview
  27. tools
  28. advanced