Show More
@@ -750,8 +750,7 b' def test_last_two_blanks():' | |||||
750 | nt.assert_true(isp.last_two_blanks('abc\nd\ne\nf\n\n\n')) |
|
750 | nt.assert_true(isp.last_two_blanks('abc\nd\ne\nf\n\n\n')) | |
751 |
|
751 | |||
752 |
|
752 | |||
753 | class CellModeCellMagics(unittest.TestCase): |
|
753 | class CellMagicsCommon(object): | |
754 | sp = isp.IPythonInputSplitter(input_mode='cell') |
|
|||
755 |
|
754 | |||
756 | def test_whole_cell(self): |
|
755 | def test_whole_cell(self): | |
757 | src = "%%cellm line\nbody\n" |
|
756 | src = "%%cellm line\nbody\n" | |
@@ -759,8 +758,15 b' class CellModeCellMagics(unittest.TestCase):' | |||||
759 | sp.push(src) |
|
758 | sp.push(src) | |
760 | nt.assert_equal(sp.cell_magic_parts, ['body\n']) |
|
759 | nt.assert_equal(sp.cell_magic_parts, ['body\n']) | |
761 | out = sp.source |
|
760 | out = sp.source | |
762 | ref = u"get_ipython()._run_cached_cell_magic(u'cellm', u'line')\n" |
|
761 | ref = u"get_ipython()._run_cached_cell_magic({u}'cellm', {u}'line')\n" | |
763 | nt.assert_equal(out, ref) |
|
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 | def test_incremental(self): |
|
771 | def test_incremental(self): | |
766 | sp = self.sp |
|
772 | sp = self.sp | |
@@ -780,28 +786,13 b' class CellModeCellMagics(unittest.TestCase):' | |||||
780 | sp.push(src) |
|
786 | sp.push(src) | |
781 | nt.assert_false(sp.push_accepts_more()) #3 |
|
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 | sp = isp.IPythonInputSplitter(input_mode='line') |
|
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 | def test_incremental(self): |
|
793 | def test_incremental(self): | |
800 | sp = self.sp |
|
794 | sp = self.sp | |
801 | sp.push('%%cellm line2\n') |
|
795 | sp.push('%%cellm line2\n') | |
802 | nt.assert_true(sp.push_accepts_more()) #1 |
|
796 | nt.assert_true(sp.push_accepts_more()) #1 | |
803 | sp.push('\n') |
|
797 | sp.push('\n') | |
804 | nt.assert_false(sp.push_accepts_more()) #2 |
|
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