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.
Use assertEqual instead of assertEquals.
Fixed #7423 -- Skip superuser creation when not running in a TTY.

Thanks to trac user galaxy4sale for the original report
and to AeroNotix for the patch.