Show More
@@ -750,17 +750,23 b' def test_last_two_blanks():' | |||
|
750 | 750 | nt.assert_true(isp.last_two_blanks('abc\nd\ne\nf\n\n\n')) |
|
751 | 751 | |
|
752 | 752 | |
|
753 | class CellModeCellMagics(unittest.TestCase): | |
|
754 | sp = isp.IPythonInputSplitter(input_mode='cell') | |
|
755 | ||
|
753 | class CellMagicsCommon(object): | |
|
754 | ||
|
756 | 755 | def test_whole_cell(self): |
|
757 | 756 | src = "%%cellm line\nbody\n" |
|
758 | 757 | sp = self.sp |
|
759 | 758 | sp.push(src) |
|
760 | 759 | nt.assert_equal(sp.cell_magic_parts, ['body\n']) |
|
761 | 760 | out = sp.source |
|
762 | ref = u"get_ipython()._run_cached_cell_magic(u'cellm', u'line')\n" | |
|
763 | nt.assert_equal(out, ref) | |
|
761 | ref = u"get_ipython()._run_cached_cell_magic({u}'cellm', {u}'line')\n" | |
|
762 | nt.assert_equal(out, py3compat.u_format(ref)) | |
|
763 | ||
|
764 | def tearDown(self): | |
|
765 | self.sp.reset() | |
|
766 | ||
|
767 | ||
|
768 | class CellModeCellMagics(CellMagicsCommon, unittest.TestCase): | |
|
769 | sp = isp.IPythonInputSplitter(input_mode='cell') | |
|
764 | 770 | |
|
765 | 771 | def test_incremental(self): |
|
766 | 772 | sp = self.sp |
@@ -780,28 +786,13 b' class CellModeCellMagics(unittest.TestCase):' | |||
|
780 | 786 | sp.push(src) |
|
781 | 787 | nt.assert_false(sp.push_accepts_more()) #3 |
|
782 | 788 | |
|
783 | def tearDown(self): | |
|
784 | self.sp.reset() | |
|
785 | ||
|
786 | 789 | |
|
787 | class LineModeCellMagics(unittest.TestCase): | |
|
790 | class LineModeCellMagics(CellMagicsCommon, unittest.TestCase): | |
|
788 | 791 | sp = isp.IPythonInputSplitter(input_mode='line') |
|
789 | 792 | |
|
790 | def test_whole_cell(self): | |
|
791 | src = "%%cellm line\nbody\n" | |
|
792 | sp = self.sp | |
|
793 | sp.push(src) | |
|
794 | nt.assert_equal(sp.cell_magic_parts, ['body\n']) | |
|
795 | out = sp.source | |
|
796 | ref = u"get_ipython()._run_cached_cell_magic(u'cellm', u'line')\n" | |
|
797 | nt.assert_equal(out, ref) | |
|
798 | ||
|
799 | 793 | def test_incremental(self): |
|
800 | 794 | sp = self.sp |
|
801 | 795 | sp.push('%%cellm line2\n') |
|
802 | 796 | nt.assert_true(sp.push_accepts_more()) #1 |
|
803 | 797 | sp.push('\n') |
|
804 | 798 | nt.assert_false(sp.push_accepts_more()) #2 |
|
805 | ||
|
806 | def tearDown(self): | |
|
807 | self.sp.reset() |
General Comments 0
You need to be logged in to leave comments.
Login now