summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDanilo Bargen <mail@dbrgn.ch>2014-11-15 12:13:05 +0100
committerTim Graham <timograham@gmail.com>2014-11-24 10:23:25 -0500
commitcdee8659763ee7044c1507bcd2202581b1744f0b (patch)
tree5759cdf3b0d8a4f04226ff016671c354245277fb /docs
parent94e2d3913d993259162b47d50ac2ab754a812f42 (diff)
Fixed #23543 -- Added docs on testing management command output.
Diffstat (limited to 'docs')
-rw-r--r--docs/howto/custom-management-commands.txt6
-rw-r--r--docs/topics/testing/tools.txt19
2 files changed, 25 insertions, 0 deletions
diff --git a/docs/howto/custom-management-commands.txt b/docs/howto/custom-management-commands.txt
index 49e5c97ded..c9695003a1 100644
--- a/docs/howto/custom-management-commands.txt
+++ b/docs/howto/custom-management-commands.txt
@@ -193,6 +193,12 @@ non-uniform locales, so you might need to:
differences when locales are changed and evaluate its impact on
predictable behavior of your command.
+Testing
+=======
+
+Information on how to test custom management commands can be found in the
+:ref:`testing docs <topics-testing-management-commands>`.
+
Command objects
===============
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 1ff0d15352..628fab06c5 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -1623,6 +1623,25 @@ manually, assign the empty list to ``mail.outbox``::
# Empty the test outbox
mail.outbox = []
+.. _topics-testing-management-commands:
+
+Management Commands
+-------------------
+
+Management commands can be tested with the
+:func:`~django.core.management.call_command` function. The output can be
+redirected into a ``StringIO`` instance::
+
+ from django.core.management import call_command
+ from django.test import TestCase
+ from django.utils.six import StringIO
+
+ class ClosepollTest(TestCase):
+ def test_command_output(self):
+ out = StringIO()
+ call_command('closepoll', stdout=out)
+ self.assertIn('Expected output', out.getvalue())
+
.. _skipping-tests:
Skipping tests