From 1491a320759c14cb11bf236d9d87e12fa95cf121 2010-07-22 00:37:41 From: Fernando Perez Date: 2010-07-22 00:37:41 Subject: [PATCH] Change get_source() api as per code review, to source_reset(). This now takes no flags, as a non-reset source access can be done simply on the .source attribute. --- diff --git a/IPython/core/blockbreaker.py b/IPython/core/blockbreaker.py index c709b52..39bc660 100644 --- a/IPython/core/blockbreaker.py +++ b/IPython/core/blockbreaker.py @@ -128,17 +128,11 @@ class BlockBreaker(object): self.source = '' self.code = None - def get_source(self, reset=False): - """Return the input source. - - Parameters - ---------- - reset : boolean - If true, all state is reset and prior input forgotten. + def source_reset(self): + """Return the input source and perform a full reset. """ out = self.source - if reset: - self.reset() + self.reset() return out def push(self, lines): diff --git a/IPython/core/tests/test_blockbreaker.py b/IPython/core/tests/test_blockbreaker.py index 0ce56bf..bc6f5ba 100644 --- a/IPython/core/tests/test_blockbreaker.py +++ b/IPython/core/tests/test_blockbreaker.py @@ -72,19 +72,17 @@ class BlockBreakerTestCase(unittest.TestCase): bb.reset() self.assertEqual(bb._buffer, []) self.assertEqual(bb.indent_spaces, 0) - self.assertEqual(bb.get_source(), '') + self.assertEqual(bb.source, '') self.assertEqual(bb.code, None) def test_source(self): self.bb._store('1') self.bb._store('2') - out = self.bb.get_source() - self.assertEqual(out, '1\n2\n') - out = self.bb.get_source(reset=True) - self.assertEqual(out, '1\n2\n') + self.assertEqual(self.bb.source, '1\n2\n') + self.assertTrue(len(self.bb._buffer)>0) + self.assertEqual(self.bb.source_reset(), '1\n2\n') self.assertEqual(self.bb._buffer, []) - out = self.bb.get_source() - self.assertEqual(out, '') + self.assertEqual(self.bb.source, '') def test_indent(self): bb = self.bb # shorthand