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