Ticket #13662: running_tests_docs.diff

File running_tests_docs.diff, 5.4 KB (added by Greg Turner, 7 years ago)
  • README

    diff --git a/README b/README
    index 6d2ce90..230b2e7 100644
    a b To contribute to Django: 
    3737
    3838    * Check out http://www.djangoproject.com/community/ for information
    3939      about getting involved.
     40
     41To run Django's included unit tests:
     42
     43    * Follow the instructions in the section "Unit tests" in
     44      docs/faq/contributing.txt, published online at http://docs.djangoproject.com/en/dev/internals/contributing/#claiming-tickets#unit-tests
     45 No newline at end of file
  • docs/internals/contributing.txt

    diff --git a/docs/internals/contributing.txt b/docs/internals/contributing.txt
    index 5130a01..9d8827f 100644
    a b for an explanation of how to write new tests. 
    874874Running the unit tests
    875875----------------------
    876876
    877 To run the tests, ``cd`` to the ``tests/`` directory and type:
     877Quickstart
     878~~~~~~~~~~
     879
     880Running the tests requires a Django settings module that defines the databases to
     881use. To run the tests with the included minimal ``settings`` module, ``cd`` to the
     882Django ``tests/`` directory and type:
     883
     884.. code-block:: bash
     885
     886    ./runtests.py --settings=test_sqlite
     887
     888Using the included ``test_sqlite.py`` allows you to get started running the tests
     889against the SQLite database backend without doing anything else on your
     890filesystem. However it should be noted that running against other database
     891backends is recommended for certain types of test cases.
     892
     893If you get an ``ImportError: No module named django.contrib`` error, you need to add your distribution of Django to your ``PYTHONPATH`` - see `Pointing Python at the new Django version`_ below.
     894
     895Using another ``settings`` module
     896~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     897
     898To run the tests with different settings, ``cd`` to the ``tests/`` directory and type:
    878899
    879900.. code-block:: bash
    880901
    881902    ./runtests.py --settings=path.to.django.settings
    882903
    883 Yes, the unit tests need a settings module, but only for database connection
    884 info. Your :setting:`DATABASES` setting needs to define two databases:
     904The :setting:`DATABASES` setting in this test settings module needs to define two
     905databases:
    885906
    886907    * A ``default`` database. This database should use the backend that
    887908      you want to use for primary testing
    info. Your :setting:`DATABASES` setting needs to define two databases: 
    892913      want. It doesn't need to use the same backend as the ``default``
    893914      database (although it can use the same backend if you want to).
    894915
    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:
     916If you're using a backend that isn't SQLite, you will need to provide other
     917details for each database:
    911918
    912919    * The :setting:`USER` option for each of your databases needs to
    913920      specify an existing user account for the database.
    character set. If your database server doesn't use UTF-8 as a default charset, 
    927934you will need to include a value for ``TEST_CHARSET`` in the settings
    928935dictionary for the applicable database.
    929936
     937Running only some of the tests
     938~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     939
     940Django's entire test suite takes a few minutes to run. To run a subset of the unit
     941tests, append the names of the test modules to the ``runtests.py`` command line.
     942
     943As an example, if you'd like to only run tests for generic relations and internationalization, type:
     944
     945.. code-block:: bash
     946
     947    ./runtests.py --settings=path.to.settings generic_relations i18n
     948
     949See the list of directories in ``tests/modeltests`` and ``tests/regressiontests``
     950for module names.
     951
     952If you just want to run a particular class of tests, you can specify a list of paths to individual test classes. For example, to run the ``TranslationTests`` of the ``i18n`` module, type:
     953
     954.. code-block:: bash
     955
     956    ./runtests.py --settings=path.to.settings i18n.TranslationTests
     957
     958You can specify an individual test like this:
     959
     960.. code-block:: bash
     961
     962    ./runtests.py --settings=path.to.settings i18n.TranslationTests.test_lazy_objects
     963
     964Running all the tests
     965~~~~~~~~~~~~~~~~~~~~~
     966
    930967If you want to run the full suite of tests, you'll need to install a number of
    931968dependencies:
    932969
    associated tests will be skipped. 
    955992.. _cmemcached: http://gijsbert.org/cmemcache/index.html
    956993.. _gettext: http://www.gnu.org/software/gettext/manual/gettext.html
    957994
    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 
    971995Contrib apps
    972996------------
    973997
Back to Top