views:

354

answers:

2

When I run tests with ./manage.py test, whatever I send to the standard output through print doesn't show. When tests fail, I see an "stdout" block per failed test, so I guess Django traps it (but doesn't show it when tests pass).

+2  A: 

You probably have some intermediate test runner, such as Nose, intercepting and storing stdout. Try either running the Django tests directly, or write to stderr instead.

John Millikin
You were right. Running the django tests directly doesn't work because there's a lot of settings things up that the custom runner does, but I was able to trace the problem and fix it. Now this is my first question here, so is it ok to edit the question to include the solution like above? Thanks!
obvio171
The best thing is to post your own answer.
Daniel Roseman
Just did. Thanks!
obvio171
+1  A: 

Checked TEST_RUNNER in settings.py, it's using a project-specific runner that calls out to Nose. Nose has the -s option to stop it from capturing stdout, but if I run:

./manage.py test -s

manage.py captures it first and throws a "no such option" error. The help for manage.py doesn't mention this, but I found that if I run:

./manage.py test -- -s

it ignores the -s and lets me capture it on the custom runner's side, passing it to Nose without a problem.

obvio171