On 27 April 2011 23:10, Shawn Milochik <[email protected]> wrote:
>
> Core devs,

I'm not a core dev, but I hope you'll find my answer useful ;)

>
> The problem is that the handler function [3] calls sys.exit() if there
> are any test failures. Given that the function is already done at this
> point, it seems redundant.
>
> I can just as easily go back to using subprocess, but it seems silly
> to shell out of Python to call a Python function. Is there any reason
> not to change this sys.exit() to a sys.stderr.write()?

Yes, there is. By calling sys.exit(bool(failure_count)) you change the
exit status of the process*. This is very useful in shell scripts:

$ python manage.py test && echo "Report success by email"

But I agree that the command shouldn't call this directly. Instead, it
would be better for all commands to return a failure indicator** and
the caller should call accordingly sys.exit() based on that.

* Another reason is that commands should always use self.stderr, not
self.stderr. I'm not sure all of them do, but they should :)

** An obvious thing would be True for success, False for failure, but
bool(None) == False, so it wouldn't be backwards compatible.

--
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to