Also test self.paste echoing, by temporarily faking the writer
(self)
| 151 | nt.assert_equal(ip.user_ns['zz'], 3.5) |
| 152 | |
| 153 | def test_paste_echo(self): |
| 154 | "Also test self.paste echoing, by temporarily faking the writer" |
| 155 | w = StringIO() |
| 156 | writer = ip.write |
| 157 | ip.write = w.write |
| 158 | code = """ |
| 159 | a = 100 |
| 160 | b = 200""" |
| 161 | try: |
| 162 | self.paste(code,'') |
| 163 | out = w.getvalue() |
| 164 | finally: |
| 165 | ip.write = writer |
| 166 | nt.assert_equal(ip.user_ns['a'], 100) |
| 167 | nt.assert_equal(ip.user_ns['b'], 200) |
| 168 | assert out == code+"\n## -- End pasted text --\n" |
| 169 | |
| 170 | def test_paste_leading_commas(self): |
| 171 | "Test multiline strings with leading commas" |