Added the possibility to pass a stdin object to a management command.

This makes testing certain features easier.

Thanks to AeroNotix for the original patch.
This commit is contained in:
Baptiste Mispelon 2014-02-17 04:24:34 +01:00
parent 3c547a423f
commit 116d39842d
2 changed files with 28 additions and 0 deletions

View file

@ -306,6 +306,7 @@ class BaseCommand(object):
self.stderr = OutputWrapper(options.get('stderr', sys.stderr))
else:
self.stderr = OutputWrapper(options.get('stderr', sys.stderr), self.style.ERROR)
self.stdin = options.get('stdin', sys.stdin) # Useful for testing
if self.can_import_settings:
from django.conf import settings # NOQA