diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2023-02-09 16:48:46 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-02-10 21:12:06 +0100 |
| commit | b784768eef75afb32f6d2ce7166551a528bce0ec (patch) | |
| tree | a375a57a50f1766538ea8a62ec49bda352d7f2b9 /docs/topics/testing/overview.txt | |
| parent | 4a89aa25c91e520c247aee428782274dcf10ffd0 (diff) | |
[4.2.x] Refs #34140 -- Applied rst code-block to non-Python examples.
Thanks to J.V. Zammit, Paolo Melchiorre, and Mariusz Felisiak for
reviews.
Backport of 534ac4829764f317cf2fbc4a18354fcc998c1425 from main.
Diffstat (limited to 'docs/topics/testing/overview.txt')
| -rw-r--r-- | docs/topics/testing/overview.txt | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/docs/topics/testing/overview.txt b/docs/topics/testing/overview.txt index e37cf23737..69f27bbeb8 100644 --- a/docs/topics/testing/overview.txt +++ b/docs/topics/testing/overview.txt @@ -75,7 +75,9 @@ Running tests ============= Once you've written tests, run them using the :djadmin:`test` command of -your project's ``manage.py`` utility:: +your project's ``manage.py`` utility: + +.. code-block:: shell $ ./manage.py test @@ -85,7 +87,9 @@ any file named ``test*.py`` under the current working directory. You can specify particular tests to run by supplying any number of "test labels" to ``./manage.py test``. Each test label can be a full Python dotted -path to a package, module, ``TestCase`` subclass, or test method. For instance:: +path to a package, module, ``TestCase`` subclass, or test method. For instance: + +.. code-block:: shell # Run all the tests in the animals.tests module $ ./manage.py test animals.tests @@ -100,13 +104,17 @@ path to a package, module, ``TestCase`` subclass, or test method. For instance:: $ ./manage.py test animals.tests.AnimalTestCase.test_animals_can_speak You can also provide a path to a directory to discover tests below that -directory:: +directory: + +.. code-block:: shell $ ./manage.py test animals/ You can specify a custom filename pattern match using the ``-p`` (or ``--pattern``) option, if your test files are named differently from the -``test*.py`` pattern:: +``test*.py`` pattern: + +.. code-block:: shell $ ./manage.py test --pattern="tests_*.py" @@ -288,7 +296,9 @@ Understanding the test output When you run your tests, you'll see a number of messages as the test runner prepares itself. You can control the level of detail of these messages with the -``verbosity`` option on the command line:: +``verbosity`` option on the command line: + +.. code-block:: shell Creating test database... Creating table myapp_animal @@ -298,7 +308,9 @@ This tells you that the test runner is creating a test database, as described in the previous section. Once the test database has been created, Django will run your tests. -If everything goes well, you'll see something like this:: +If everything goes well, you'll see something like this: + +.. code-block:: shell ---------------------------------------------------------------------- Ran 22 tests in 0.221s @@ -306,7 +318,9 @@ If everything goes well, you'll see something like this:: OK If there are test failures, however, you'll see full details about which tests -failed:: +failed: + +.. code-block:: shell ====================================================================== FAIL: test_was_published_recently_with_future_poll (polls.tests.PollMethodTests) |
