Show More
@@ -688,7 +688,7 b' class FooFoo(Magics):' | |||||
688 | def line_foo(self, line): |
|
688 | def line_foo(self, line): | |
689 | "I am line foo" |
|
689 | "I am line foo" | |
690 | pass |
|
690 | pass | |
691 |
|
691 | |||
692 | @cell_magic("foo") |
|
692 | @cell_magic("foo") | |
693 | def cell_foo(self, line, cell): |
|
693 | def cell_foo(self, line, cell): | |
694 | "I am cell foo, not line foo" |
|
694 | "I am cell foo, not line foo" | |
@@ -721,4 +721,23 b' def test_multiple_magics():' | |||||
721 | nt.assert_true(mm.magics['line']['foo'].im_self is foo1) |
|
721 | nt.assert_true(mm.magics['line']['foo'].im_self is foo1) | |
722 | mm.register(foo2) |
|
722 | mm.register(foo2) | |
723 | nt.assert_true(mm.magics['line']['foo'].im_self is foo2) |
|
723 | nt.assert_true(mm.magics['line']['foo'].im_self is foo2) | |
724 | No newline at end of file |
|
724 | ||
|
725 | def test_alias_magic(): | |||
|
726 | """Test %alias_magic.""" | |||
|
727 | ip = get_ipython() | |||
|
728 | mm = ip.magics_manager | |||
|
729 | ||||
|
730 | # Basic operation: both cell and line magics are created, if possible. | |||
|
731 | ip.run_line_magic('alias_magic', 'timeit_alias timeit') | |||
|
732 | nt.assert_true('timeit_alias' in mm.magics['line']) | |||
|
733 | nt.assert_true('timeit_alias' in mm.magics['cell']) | |||
|
734 | ||||
|
735 | # --cell is specified, line magic not created. | |||
|
736 | ip.run_line_magic('alias_magic', '--cell timeit_cell_alias timeit') | |||
|
737 | nt.assert_false('timeit_cell_alias' in mm.magics['line']) | |||
|
738 | nt.assert_true('timeit_cell_alias' in mm.magics['cell']) | |||
|
739 | ||||
|
740 | # Test that line alias is created successfully. | |||
|
741 | ip.run_line_magic('alias_magic', '--line env_alias env') | |||
|
742 | nt.assert_equal(ip.run_line_magic('env', ''), | |||
|
743 | ip.run_line_magic('env_alias', '')) |
General Comments 0
You need to be logged in to leave comments.
Login now