def test_tb_syntaxerror():
    'test %tb after a SyntaxError'
    ip = get_ipython()
    ip.run_cell('for')
    save_stdout = sys.stdout
    try:
        sys.stdout = StringIO()
        ip.run_cell('%tb')
        out = sys.stdout.getvalue()
    finally:
        sys.stdout = save_stdout
    last_line = out.rstrip().splitlines()[(- 1)].strip()
    nt.assert_equal(last_line, 'SyntaxError: invalid syntax')
test %tb after a SyntaxError
def test_tb_syntaxerror():
    
    ip = get_ipython()
    ip.run_cell('for')
    save_stdout = sys.stdout
    try:
        sys.stdout = StringIO()
        ip.run_cell('%tb')
        out = sys.stdout.getvalue()
    finally:
        sys.stdout = save_stdout
    last_line = out.rstrip().splitlines()[(- 1)].strip()
    nt.assert_equal(last_line, 'SyntaxError: invalid syntax')