def METHOD_NAME(self, func, expected):
    s = StringIO.StringIO()
    save_stdout = sys.stdout
    sys.stdout = s
    dis.dis(func)
    sys.stdout = save_stdout
    got = s.getvalue()
    # Trim trailing blanks (if any).
    lines = got.split('\n')
    lines = [line.rstrip() for line in lines]
    expected = expected.split("\n")
    import difflib
    if expected != lines:
        self.fail(
            "events did not match expectation:\n" +
            "\n".join(difflib.ndiff(expected,
                                    lines)))