def test_printout(self): stdout, sys.stdout = sys.stdout, StringIO() printout() self.assertEqual(sys.stdout.getvalue(), '<--""\n Level WARNING\n') sys.stdout = stdout