#23543 closed Cleanup/optimization (fixed)
Documentation how to test custom management command missing
Reported by: | wittwerch | Owned by: | Danilo Bargen |
---|---|---|---|
Component: | Documentation | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Lagovas, mail@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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!
Change History (11)
comment:1 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 10 years ago
comment:3 by , 10 years ago
Cc: | added |
---|
comment:4 by , 10 years ago
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
).
comment:5 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 10 years ago
Cc: | added |
---|---|
Has patch: | set |
Pull request: https://github.com/django/django/pull/3517
comment:8 by , 10 years ago
Patch needs improvement: | unset |
---|
comment:9 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
You can test commands like any other function. Just
and test result or behavior of your command. I think no sense for writing how to test all functions or methods from docs.