Make a unit test work when sys.stderr.isatty() == False