#23663: Commands classes are not properly testable due to their initialization
in
execute() method!
-------------------------------------+-------------------------------------
Reporter: daveoncode | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.7
Component: Core (Management | Keywords: test, tdd, management,
commands) | commands
Severity: Normal | Has patch: 0
Triage Stage: Unreviewed | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
I was writing a series of tests for a custom command, but I get:
'''AttributeError: 'Command' object has no attribute 'stderr''''''''
I realized that the problem is that references to "stderr" and "stdout"
are initialized in the execute() method!
This makes commands classes untestable, or better, I can write tests but
tests that are not unitary, this is against the principles of TDD, I
should not run a command to test it, instead I should write tests for each
single little piece of logic that makes my command do the job.
Please, move initialization logic into __init__ so we can test commands
methods separately.
--
Ticket URL: <https://code.djangoproject.com/ticket/23663>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.38ad52833bba09ac945b44aa0e932715%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.