Skip to content

Commit

Permalink
Add a demo of an extra LF @ EOF bug
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Sep 25, 2019
1 parent d225ead commit 557b985
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from redbaron import RedBaron


Expand All @@ -23,3 +25,26 @@ def test_on_copied_blocknode_set_body():
def test_find_empty_call():
red = RedBaron("a()")
assert red.find("call") is red[0][1]


@pytest.mark.parametrize(
'original_src, transformed_src',
(
(
"\nimport i1\nimport i2\n",
"\nimport i1\nimport i2\nimport i1\n",
),
(
"\nimport i1\nimport i2\n\nif True:\n main()\n",
"\nimport i1\nimport i2\nimport i1\n\nif True:\n main()\n",
),
)
)
def test_does_not_dumps_extra_trailing_lf_after_root_insert_if_nested(
original_src,
transformed_src,
):
red = RedBaron(original_src)
imp1, imp2 = red.find_all('import')
imp2.insert_after(imp1)
assert red.dumps() == transformed_src

0 comments on commit 557b985

Please sign in to comment.