From 9c4b68605ce60c4650b30289cabcf941fa7e5fa7 Mon Sep 17 00:00:00 2001 From: Hamad AlGhanim Date: Wed, 18 Oct 2017 10:07:17 -0700 Subject: [PATCH] fix for #925 (#930) * fix for adding newline * added test to ensure fix #925 --- pipenv/utils.py | 4 +++- tests/test_utils.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index bb118b7c..bf99cdd5 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -290,7 +290,9 @@ def cleanup_toml(tml): # Insert a newline after the heading. if after: new_toml.append('') - + + # adding new line at the end of the TOML file + new_toml.append('') toml = '\n'.join(new_toml) return toml diff --git a/tests/test_utils.py b/tests/test_utils.py index b094a346..4922d294 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -186,3 +186,21 @@ class TestUtils: pipenv.utils.download_file(url, output) assert os.path.exists(output) os.remove(output) + + def test_new_line_end_of_toml_file(this): + # toml file that needs clean up + toml = """ +[dev-packages] + +"flake8" = ">=3.3.0,<4" +pytest = "*" +mock = "*" +sphinx = "<=1.5.5" +"-e ." = "*" +twine = "*" +"sphinx-click" = "*" +"pytest-xdist" = "*" + """ + new_toml = pipenv.utils.cleanup_toml(toml) + # testing if the end of the generated file contains a newline + assert new_toml[-1] == '\n'