def _test_runner(self,runner,source,output):
        """Test that a given runner's input/output match."""
        
        runner.run_source(source)
        out = self.out.getvalue()
        #out = ''
        # this output contains nasty \r\n lineends, and the initial ipython
        # banner.  clean it up for comparison, removing lines of whitespace
        output_l = [l for l in output.splitlines() if l and not l.isspace()]
        out_l = [l for l in out.splitlines() if l and not l.isspace()]
        mismatch  = 0
        if len(output_l) != len(out_l):
            message = ("Mismatch in number of lines\n\n"
                       "Expected:\n"
                       "~~~~~~~~~\n"
                       "%s\n\n"
                       "Got:\n"
                       "~~~~~~~~~\n"
                       "%s"
                       ) % ("\n".join(output_l), "\n".join(out_l))
            self.fail(message)
        for n in range(len(output_l)):
            # Do a line-by-line comparison
            ol1 = output_l[n].strip()
            ol2 = out_l[n].strip()
            if ol1 != ol2:
                mismatch += 1
                if VERBOSE:
                    print('<<< line %s does not match:' % n)
                    print(repr(ol1))
                    print(repr(ol2))
                    print('>>>')
        self.assert_(mismatch==0,'Number of mismatched lines: %s' %
                     mismatch)
dataset/ETHPy150Open ipython/ipython-py3k/IPython/lib/tests/test_irunner.py/RunnerTestCase._test_runner/original