Modernized printing tests.

Using recipe 14.1 described in "Python Cookbook", mock.patch works much
better.