mirror of
https://github.com/django/django.git
synced 2025-08-09 21:38:18 +00:00
[1.7.x] Fixed #23543 -- Added docs on testing management command output.
Backport of cdee865976
from master
This commit is contained in:
parent
e10c5a8fdd
commit
60cf46fdf5
2 changed files with 25 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue