[Django] #23543: Documentation how to test custom management command missing

12 views
Skip to first unread message

Django

unread,
Sep 23, 2014, 3:09:25 AM9/23/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+--------------------
Reporter: wittwerch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
The documentation about custom management command misses a few points how
to properly test them.
=> https://docs.djangoproject.com/en/1.7/howto/custom-management-commands/

For example the documentation states that you should use self.stdout: "By
using these proxies, it becomes much easier to test your custom command"
But how to actually test the output is missing. A complete example with
call_command would be great!

--
Ticket URL: <https://code.djangoproject.com/ticket/23543>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 23, 2014, 3:35:40 AM9/23/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------

Reporter: wittwerch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by claudep):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:1>

Django

unread,
Sep 26, 2014, 9:08:30 AM9/26/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------

Reporter: wittwerch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Lagovas):

You can test commands like any other function. Just


{{{
from django.core.management import call_command
class SomeTest(TestCase):
def test_command(self):
call_command('your_command', *args, **kwargs)
self.assertTrue(somethingDone())
}}}


and test result or behavior of your command. I think no sense for writing
how to test all functions or methods from docs.

--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:2>

Django

unread,
Sep 26, 2014, 9:10:01 AM9/26/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------

Reporter: wittwerch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Lagovas):

* cc: Lagovas (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:3>

Django

unread,
Sep 26, 2014, 1:53:49 PM9/26/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------

Reporter: wittwerch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by claudep):

I think an example wouldn't hurt, and show how you can catch the command
output with `six.StringIO` (see `tests/user_commands/tests.py`).

--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:4>

Django

unread,
Nov 15, 2014, 5:57:41 AM11/15/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------
Reporter: wittwerch | Owner: dbrgn
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by dbrgn):

* status: new => assigned
* owner: nobody => dbrgn


--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:5>

Django

unread,
Nov 15, 2014, 6:15:34 AM11/15/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------
Reporter: wittwerch | Owner: dbrgn
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by dbrgn):

* cc: mail@… (added)
* has_patch: 0 => 1


Comment:

Pull request: https://github.com/django/django/pull/3517

--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:6>

Django

unread,
Nov 16, 2014, 11:26:20 AM11/16/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------
Reporter: wittwerch | Owner: dbrgn
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


Comment:

Comments for improvement are on the PR.

--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:7>

Django

unread,
Nov 21, 2014, 4:48:05 PM11/21/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------
Reporter: wittwerch | Owner: dbrgn
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:8>

Django

unread,
Nov 24, 2014, 10:29:08 AM11/24/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------
Reporter: wittwerch | Owner: dbrgn
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"cdee8659763ee7044c1507bcd2202581b1744f0b"]:
{{{
#!CommitTicketReference repository=""
revision="cdee8659763ee7044c1507bcd2202581b1744f0b"
Fixed #23543 -- Added docs on testing management command output.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:9>

Django

unread,
Nov 24, 2014, 10:29:40 AM11/24/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------
Reporter: wittwerch | Owner: dbrgn
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"60cf46fdf5176eb24ba4d47441ed24104f1493cc"]:
{{{
#!CommitTicketReference repository=""
revision="60cf46fdf5176eb24ba4d47441ed24104f1493cc"
[1.7.x] Fixed #23543 -- Added docs on testing management command output.

Backport of cdee8659763ee7044c1507bcd2202581b1744f0b from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:10>

Django

unread,
Nov 24, 2014, 10:29:42 AM11/24/14
to django-...@googlegroups.com
#23543: Documentation how to test custom management command missing
--------------------------------------+------------------------------------
Reporter: wittwerch | Owner: dbrgn
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"276332d85c76a4de9fc1cb4bcb2f1636c0322414"]:
{{{
#!CommitTicketReference repository=""
revision="276332d85c76a4de9fc1cb4bcb2f1636c0322414"
[1.6.x] Fixed #23543 -- Added docs on testing management command output.

Backport of cdee8659763ee7044c1507bcd2202581b1744f0b from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23543#comment:11>

Reply all
Reply to author
Forward
0 new messages