Skip to content

Commit 676e8a4

Browse files
committed
test: add unit tests for max-consecutive-empty-lines
1 parent 0a2a422 commit 676e8a4

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

fprettify/tests/unittests.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,61 @@ def test_comments(self):
214214
outstring_exp_strip_spacing3,
215215
)
216216

217+
def test_max_consecutive_empty_lines(self):
218+
"""test limiting consecutive empty lines"""
219+
instring = (
220+
"program demo\n"
221+
"\n"
222+
"\n"
223+
"\n"
224+
" a = 1\n"
225+
"\n"
226+
"\n"
227+
"\n"
228+
" b = 2\n"
229+
"\n"
230+
"\n"
231+
"end program demo\n"
232+
)
233+
234+
outstring_exp_default = (
235+
"program demo\n"
236+
"\n"
237+
" a = 1\n"
238+
"\n"
239+
" b = 2\n"
240+
"\n"
241+
"end program demo\n"
242+
)
243+
244+
outstring_exp_zero = (
245+
"program demo\n"
246+
" a = 1\n"
247+
" b = 2\n"
248+
"end program demo\n"
249+
)
250+
251+
outstring_exp_two = (
252+
"program demo\n"
253+
"\n"
254+
"\n"
255+
" a = 1\n"
256+
"\n"
257+
"\n"
258+
" b = 2\n"
259+
"\n"
260+
"\n"
261+
"end program demo\n"
262+
)
263+
264+
self.assert_fprettify_result([], instring, outstring_exp_default)
265+
self.assert_fprettify_result(
266+
["--max-consecutive-empty-lines", "0"], instring, outstring_exp_zero
267+
)
268+
self.assert_fprettify_result(
269+
["--max-consecutive-empty-lines", "2"], instring, outstring_exp_two
270+
)
271+
217272
def test_directive(self):
218273
"""
219274
test deactivate directives '!&' (inline) and '!&<', '!&>' (block)

0 commit comments

Comments
 (0)