def METHOD_NAME(self, teststr, expected_out, r, w, e=None):
    w.write(teststr)
    w.close()
    got = r.read()
    self.assertEqual(expected_out, got.strip(), "wrote %r read %r" %
                     (teststr, got))
    if e is not None:
        got = e.read()
        self.assertFalse(got, "unexpected %r on stderr" % got)