Replacing ``sys.stdout`` have no effect over ``print`` statement. This test script outputs ``AssertionError: 0 chars printed, instead of 3``, after printing 'foo' in the stdout. ```python import StringIO import sys sio = StringIO() stdout = sys.stdout sys.stdout = sio print 'foo' sys.stdout = stdout chars = sio.tell() assert chars == 3, '%s chars printed, instead of 3' % chars ```
Replacing
sys.stdouthave no effect overprintstatement.This test script outputs
AssertionError: 0 chars printed, instead of 3, after printing 'foo' in the stdout.