'Also test self.paste echoing, by temporarily faking the writer'

def test_paste_echo(self):

    w = StringIO()
    writer = ip.write
    ip.write = w.write
    code = '\n                                a    =    100\n                                b    =    200'
    try:
        self.paste(code, '')
        out = w.getvalue()
    finally:
        ip.write = writer
    nt.assert_equal(ip.user_ns['a'], 100)
    nt.assert_equal(ip.user_ns['b'], 200)
    nt.assert_equal(out, (code + '\n##    --    End    pasted    text    --\n'))
