877 | | To run the tests, ``cd`` to the ``tests/`` directory and type: |
| 877 | Quickstart |
| 878 | ~~~~~~~~~~ |
| 879 | |
| 880 | Running the tests requires a Django settings module that defines the databases |
| 881 | to use. To run the tests with the included minimal ``settings`` module, ``cd`` |
| 882 | to the Django ``tests/`` directory and type: |
| 883 | |
| 884 | .. code-block:: bash |
| 885 | |
| 886 | ./runtests.py --settings=test_sqlite |
| 887 | |
| 888 | Using the included ``test_sqlite.py`` allows you to get started running the |
| 889 | tests against the SQLite database backend without doing anything else on your |
| 890 | filesystem. However it should be noted that running against other database |
| 891 | backends is recommended for certain types of test cases. |
| 892 | |
| 893 | If you get an ``ImportError: No module named django.contrib`` error, you need |
| 894 | to add your distribution of Django to your ``PYTHONPATH``. This can be done |
| 895 | temporarily by symlinking the django directory. To do so, type: |
| 896 | |
| 897 | .. code-block:: bash |
| 898 | |
| 899 | ln -s ../django/ django |
| 900 | |
| 901 | For more details, and better options if you plan on using this version of |
| 902 | Django long-term, read `Pointing Python at the new Django version`_ below. |
| 903 | |
| 904 | Using another ``settings`` module |
| 905 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 906 | |
| 907 | To run the tests with different settings, ``cd`` to the ``tests/`` directory |
| 908 | and type: |
895 | | As a convenience, a minimal settings file, using two in memory SQLite |
896 | | databases, is included in your Django distribution. It is called |
897 | | ``test_sqlite``, and is included in the ``tests`` directory. This allows you to |
898 | | get started running the tests against the sqlite database without doing |
899 | | anything on your filesystem. However it should be noted that running against |
900 | | other database backends is recommended for certain types of test cases. |
901 | | |
902 | | To run the tests with this included settings file, ``cd`` |
903 | | to the ``tests/`` directory and type: |
904 | | |
905 | | .. code-block:: bash |
906 | | |
907 | | ./runtests.py --settings=test_sqlite |
908 | | |
909 | | If you're using another backend, you will need to provide other details for |
910 | | each database: |
| 926 | If you're using a backend that isn't SQLite, you will need to provide other |
| 927 | details for each database: |
| 947 | Running only some of the tests |
| 948 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 949 | |
| 950 | Django's entire test suite takes a few minutes to run. To run a subset of the |
| 951 | unit tests, append the names of the test modules to the ``runtests.py`` |
| 952 | command line. |
| 953 | |
| 954 | As an example, if you'd like to only run tests for generic relations and |
| 955 | internationalization, type: |
| 956 | |
| 957 | .. code-block:: bash |
| 958 | |
| 959 | ./runtests.py --settings=path.to.settings generic_relations i18n |
| 960 | |
| 961 | See the list of directories in ``tests/modeltests`` and |
| 962 | ``tests/regressiontests`` for module names. |
| 963 | |
| 964 | If you just want to run a particular class of tests, you can specify a list of |
| 965 | paths to individual test classes. For example, to run the ``TranslationTests`` |
| 966 | of the ``i18n`` module, type: |
| 967 | |
| 968 | .. code-block:: bash |
| 969 | |
| 970 | ./runtests.py --settings=path.to.settings i18n.TranslationTests |
| 971 | |
| 972 | You can specify an individual test like this: |
| 973 | |
| 974 | .. code-block:: bash |
| 975 | |
| 976 | ./runtests.py --settings=path.to.settings i18n.TranslationTests.test_lazy_objects |
| 977 | |
| 978 | Running all the tests |
| 979 | ~~~~~~~~~~~~~~~~~~~~~ |
| 980 | |
958 | | To run a subset of the unit tests, append the names of the test modules to the |
959 | | ``runtests.py`` command line. See the list of directories in |
960 | | ``tests/modeltests`` and ``tests/regressiontests`` for module names. |
961 | | |
962 | | As an example, if Django is not in your ``PYTHONPATH``, you placed |
963 | | ``settings.py`` in the ``tests/`` directory, and you'd like to only run tests |
964 | | for generic relations and internationalization, type: |
965 | | |
966 | | .. code-block:: bash |
967 | | |
968 | | PYTHONPATH=`pwd`/.. |
969 | | ./runtests.py --settings=settings generic_relations i18n |
970 | | |