From 41fd0b41f621b6e10dba5333d8b57200dbbe0fc5 2011-03-13 12:51:48 From: Thomas Kluyver Date: 2011-03-13 12:51:48 Subject: [PATCH] Add test for magic macro command. --- diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index 271846f..189f272 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -173,6 +173,18 @@ def test_shist(): yield nt.assert_equal,s.get(2),'world' shutil.rmtree(tfile) + +def test_macro(): + ip = get_ipython() + ip.history_manager.reset() # Clear any existing history. + cmds = ["a=1", "def b():\n return a**2", "print(a,b())"] + for cmd in cmds: + ip.history_manager.store_inputs(cmd) + ip.magic("macro test 1-3") + nt.assert_equal(ip.user_ns["test"].value, "\n".join(cmds)+"\n") + + # List macros. This goes to stdout, so just check it doesn't crash. + ip.magic("macro") # XXX failing for now, until we get clearcmd out of quarantine. But we should