diff options
Diffstat (limited to 'docs/topics/testing')
| -rw-r--r-- | docs/topics/testing/tools.txt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 8caf19dce3..ae26523980 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -1568,6 +1568,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 |
