From 6521c63e50dc922f3afed5f571d0390e4cb1d197 2013-05-25 17:27:03 From: Thomas Kluyver Date: 2013-05-25 17:27:03 Subject: [PATCH] Failing test for gh-3246 --- diff --git a/IPython/frontend/terminal/tests/test_interactivshell.py b/IPython/frontend/terminal/tests/test_interactivshell.py index 9a13b50..6ab4acb 100644 --- a/IPython/frontend/terminal/tests/test_interactivshell.py +++ b/IPython/frontend/terminal/tests/test_interactivshell.py @@ -171,6 +171,7 @@ class InteractiveShellTestCase(unittest.TestCase): expected = [ py3compat.unicode_to_str(e, enc) for e in expected ] self.assertEqual(hist, expected) +class TerminalMagicsTestCase(unittest.TestCase): def test_paste_magics_message(self): """Test that an IndentationError while using paste magics doesn't trigger a message about paste magics and also the opposite.""" @@ -187,3 +188,16 @@ class InteractiveShellTestCase(unittest.TestCase): with tt.AssertNotPrints("If you want to paste code into IPython, try the " "%paste and %cpaste magic functions."): tm.store_or_execute(s, name=None) + + def test_paste_magics_blankline(self): + """Test that code with a blank line doesn't get split (gh-3246).""" + ip = get_ipython() + s = ('def pasted_func(a):\n' + ' b = a+1\n' + '\n' + ' return b') + + tm = ip.magics_manager.registry['TerminalMagics'] + tm.store_or_execute(s, name=None) + + self.assertEqual(ip.user_ns['pasted_func'](54), 55)