Test traceback offset in `ipython script.py`
()
| 589 | |
| 590 | @dec.knownfailureif(sys.platform == 'win32', "writes to io.stdout aren't captured on Windows") |
| 591 | def test_script_tb(): |
| 592 | """Test traceback offset in `ipython script.py`""" |
| 593 | with TemporaryDirectory() as td: |
| 594 | path = pjoin(td, 'foo.py') |
| 595 | with open(path, 'w') as f: |
| 596 | f.write('\n'.join([ |
| 597 | "def foo():", |
| 598 | " return bar()", |
| 599 | "def bar():", |
| 600 | " raise RuntimeError('hello!')", |
| 601 | "foo()", |
| 602 | ])) |
| 603 | out, err = tt.ipexec(path) |
| 604 | nt.assert_not_in("execfile", out) |
| 605 | nt.assert_in("RuntimeError", out) |
| 606 | nt.assert_equal(out.count("---->"), 3) |
| 607 |