mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Unified listing of shell commands/code
- use code-block:: bash - prefix the command with $
This commit is contained in:
parent
0dd9075622
commit
80027d2c38
5 changed files with 45 additions and 28 deletions
|
@ -30,15 +30,17 @@ sample settings module that uses the SQLite database. To run the tests:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone git@github.com:django/django.git django-repo
|
||||
cd django-repo/tests
|
||||
PYTHONPATH=..:$PYTHONPATH ./runtests.py
|
||||
$ git clone git@github.com:django/django.git django-repo
|
||||
$ cd django-repo/tests
|
||||
$ PYTHONPATH=..:$PYTHONPATH ./runtests.py
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
|
||||
Older versions of Django required specifying a settings file::
|
||||
Older versions of Django required specifying a settings file:
|
||||
|
||||
PYTHONPATH=..:$PYTHONPATH python ./runtests.py --settings=test_sqlite
|
||||
.. code-block:: bash
|
||||
|
||||
$ PYTHONPATH=..:$PYTHONPATH python ./runtests.py --settings=test_sqlite
|
||||
|
||||
``runtests.py`` now uses ``test_sqlite`` by default if settings aren't provided
|
||||
through either ``--settings`` or :envvar:`DJANGO_SETTINGS_MODULE`.
|
||||
|
@ -111,7 +113,7 @@ internationalization, type:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
./runtests.py --settings=path.to.settings generic_relations i18n
|
||||
$ ./runtests.py --settings=path.to.settings generic_relations i18n
|
||||
|
||||
How do you find out the names of individual tests? Look in ``tests/`` — each
|
||||
directory name there is the name of a test. Contrib app names are also valid
|
||||
|
@ -123,13 +125,13 @@ of the ``i18n`` module, type:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
./runtests.py --settings=path.to.settings i18n.tests.TranslationTests
|
||||
$ ./runtests.py --settings=path.to.settings i18n.tests.TranslationTests
|
||||
|
||||
Going beyond that, you can specify an individual test method like this:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
./runtests.py --settings=path.to.settings i18n.tests.TranslationTests.test_lazy_objects
|
||||
$ ./runtests.py --settings=path.to.settings i18n.tests.TranslationTests.test_lazy_objects
|
||||
|
||||
Running the Selenium tests
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -141,7 +143,7 @@ the tests with the ``--selenium`` option:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
./runtests.py --settings=test_sqlite --selenium admin_inlines
|
||||
$ ./runtests.py --settings=test_sqlite --selenium admin_inlines
|
||||
|
||||
|
||||
.. _running-unit-tests-dependencies:
|
||||
|
@ -165,9 +167,11 @@ dependencies:
|
|||
|
||||
You can find these dependencies in `pip requirements files`_ inside the
|
||||
``tests/requirements`` directory of the Django source tree and install them
|
||||
like so::
|
||||
like so:
|
||||
|
||||
pip install -r tests/requirements/py2.txt # Python 3: py3.txt
|
||||
.. code-block:: bash
|
||||
|
||||
$ pip install -r tests/requirements/py2.txt # Python 3: py3.txt
|
||||
|
||||
You can also install the database adapter(s) of your choice using
|
||||
``oracle.txt``, ``mysql.txt``, or ``postgres.txt``.
|
||||
|
@ -200,13 +204,17 @@ Contributors are encouraged to run coverage on the test suite to identify areas
|
|||
that need additional tests. The coverage tool installation and use is described
|
||||
in :ref:`testing code coverage<topics-testing-code-coverage>`.
|
||||
|
||||
To run coverage on the Django test suite using the standard test settings::
|
||||
To run coverage on the Django test suite using the standard test settings:
|
||||
|
||||
coverage run ./runtests.py --settings=test_sqlite
|
||||
.. code-block:: bash
|
||||
|
||||
After running coverage, generate the html report by running::
|
||||
$ coverage run ./runtests.py --settings=test_sqlite
|
||||
|
||||
coverage html
|
||||
After running coverage, generate the html report by running:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ coverage html
|
||||
|
||||
When running coverage for the Django tests, the included ``.coveragerc``
|
||||
settings file defines ``coverage_html`` as the output directory for the report
|
||||
|
@ -225,6 +233,8 @@ multiple modules by using a ``tests`` directory in the normal Python way.
|
|||
If you have URLs that need to be mapped, put them in ``tests/urls.py``.
|
||||
|
||||
To run tests for just one contrib app (e.g. ``auth``), use the same
|
||||
method as above::
|
||||
method as above:
|
||||
|
||||
./runtests.py --settings=settings django.contrib.auth
|
||||
.. code-block:: bash
|
||||
|
||||
$ ./runtests.py --settings=settings django.contrib.auth
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue