##// END OF EJS Templates
Adds p.break_ for explicit newlines in lib.pretty...
Alex Rudy -
Show More
@@ -230,6 +230,16 b' class PrettyPrinter(_PrettyPrinterBase):'
230 230 self.buffer_width += width
231 231 self._break_outer_groups()
232 232
233 def break_(self):
234 """
235 Explicitly insert a newline into the output, maintaining correct indentation.
236 """
237 self.flush()
238 self.output.write(self.newline)
239 self.output.write(' ' * self.indentation)
240 self.output_width = self.indentation
241 self.buffer_width = 0
242
233 243
234 244 def begin_group(self, indent=0, open=''):
235 245 """
@@ -58,6 +58,13 b' class NoModule(object):'
58 58
59 59 NoModule.__module__ = None
60 60
61 class Breaking(object):
62 def _repr_pretty_(self, p, cycle):
63 with p.group(4,"TG: ",":"):
64 p.text("Breaking(")
65 p.break_()
66 p.text(")")
67
61 68
62 69 def test_indentation():
63 70 """Test correct indentation in groups"""
@@ -118,3 +125,11 b' def test_pprint_nomod():'
118 125 """
119 126 output = pretty.pretty(NoModule)
120 127 nt.assert_equal(output, 'NoModule')
128
129 def test_pprint_break():
130 """
131 Test that p.break_ produces expected output
132 """
133 output = pretty.pretty(Breaking())
134 expected = "TG: Breaking(\n ):"
135 nt.assert_equal(output, expected)
General Comments 0
You need to be logged in to leave comments. Login now