##// END OF EJS Templates
Change get_source() api as per code review, to source_reset()....
Fernando Perez -
Show More
@@ -128,16 +128,10 b' class BlockBreaker(object):'
128 self.source = ''
128 self.source = ''
129 self.code = None
129 self.code = None
130
130
131 def get_source(self, reset=False):
131 def source_reset(self):
132 """Return the input source.
132 """Return the input source and perform a full reset.
133
134 Parameters
135 ----------
136 reset : boolean
137 If true, all state is reset and prior input forgotten.
138 """
133 """
139 out = self.source
134 out = self.source
140 if reset:
141 self.reset()
135 self.reset()
142 return out
136 return out
143
137
@@ -72,19 +72,17 b' class BlockBreakerTestCase(unittest.TestCase):'
72 bb.reset()
72 bb.reset()
73 self.assertEqual(bb._buffer, [])
73 self.assertEqual(bb._buffer, [])
74 self.assertEqual(bb.indent_spaces, 0)
74 self.assertEqual(bb.indent_spaces, 0)
75 self.assertEqual(bb.get_source(), '')
75 self.assertEqual(bb.source, '')
76 self.assertEqual(bb.code, None)
76 self.assertEqual(bb.code, None)
77
77
78 def test_source(self):
78 def test_source(self):
79 self.bb._store('1')
79 self.bb._store('1')
80 self.bb._store('2')
80 self.bb._store('2')
81 out = self.bb.get_source()
81 self.assertEqual(self.bb.source, '1\n2\n')
82 self.assertEqual(out, '1\n2\n')
82 self.assertTrue(len(self.bb._buffer)>0)
83 out = self.bb.get_source(reset=True)
83 self.assertEqual(self.bb.source_reset(), '1\n2\n')
84 self.assertEqual(out, '1\n2\n')
85 self.assertEqual(self.bb._buffer, [])
84 self.assertEqual(self.bb._buffer, [])
86 out = self.bb.get_source()
85 self.assertEqual(self.bb.source, '')
87 self.assertEqual(out, '')
88
86
89 def test_indent(self):
87 def test_indent(self):
90 bb = self.bb # shorthand
88 bb = self.bb # shorthand
General Comments 0
You need to be logged in to leave comments. Login now