index.rst 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ===========================
  2. pytest-django Documentation
  3. ===========================
  4. pytest-django is a plugin for `pytest`_ that provides a set of useful tools
  5. for testing `Django`_ applications and projects.
  6. .. _pytest: https://pytest.org/
  7. .. _Django: https://www.djangoproject.com/
  8. Quick Start
  9. ===========
  10. .. code-block:: bash
  11. $ pip install pytest-django
  12. Make sure ``DJANGO_SETTINGS_MODULE`` is defined (see
  13. :ref:`configuring_django_settings`) and make your tests discoverable
  14. (see :ref:`faq-tests-not-being-picked-up`):
  15. .. code-block:: ini
  16. # -- FILE: pytest.ini (or tox.ini)
  17. [pytest]
  18. DJANGO_SETTINGS_MODULE = test_settings
  19. # -- recommended but optional:
  20. python_files = tests.py test_*.py *_tests.py
  21. Run your tests with ``pytest``:
  22. .. code-block:: bash
  23. $ pytest
  24. Why would I use this instead of Django's manage.py test command?
  25. ================================================================
  26. Running the test suite with pytest offers some features that are not present in Django's standard test mechanism:
  27. * Less boilerplate: no need to import unittest, create a subclass with methods. Just write tests as regular functions.
  28. * `Manage test dependencies with fixtures`_.
  29. * Run tests in multiple processes for increased speed.
  30. * There are a lot of other nice plugins available for pytest.
  31. * Easy switching: Existing unittest-style tests will still work without any modifications.
  32. See the `pytest documentation`_ for more information on pytest.
  33. .. _Manage test dependencies with fixtures: http://docs.pytest.org/en/latest/fixture.html
  34. .. _pytest documentation: http://docs.pytest.org/
  35. Bugs? Feature Suggestions?
  36. ==========================
  37. Report issues and feature requests at the `GitHub issue tracker`_.
  38. .. _GitHub issue tracker: http://github.com/pytest-dev/pytest-django/issues
  39. Table of Contents
  40. =================
  41. .. toctree::
  42. :maxdepth: 3
  43. tutorial
  44. configuring_django
  45. managing_python_path
  46. usage
  47. database
  48. helpers
  49. faq
  50. contributing
  51. changelog
  52. Indices and Tables
  53. ==================
  54. * :ref:`genindex`
  55. * :ref:`modindex`