summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@idiap.ch>2021-09-28 23:24:57 +0200
committerSamuel Gaist <samuel.gaist@idiap.ch>2021-09-30 22:16:56 +0200
commit960d208ae5be5e7b0391c17fd3d31408adb1538e (patch)
tree9979694a2f28cd7badc36988763618d74eb09738 /tests/unit
parent995e016b9d888fea02bedeb5be8ea7f01b694b58 (diff)
downloadisort-960d208ae5be5e7b0391c17fd3d31408adb1538e.tar.gz
feature: implement lines before imports
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_isort.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/unit/test_isort.py b/tests/unit/test_isort.py
index bf22d34b..eb0177fb 100644
--- a/tests/unit/test_isort.py
+++ b/tests/unit/test_isort.py
@@ -1473,6 +1473,19 @@ def test_order_by_type() -> None:
)
+def test_custom_lines_before_import_section() -> None:
+ """Test the case where the number of lines to output after imports has been explicitly set."""
+ test_input = "from a import b\nfrom c import d\nfoo = 'bar'\n"
+
+ # default case is no line added before the import
+ assert isort.code(test_input) == ("from a import b\nfrom c import d\n\nfoo = 'bar'\n")
+
+ # test again with a custom number of lines before the import section
+ assert isort.code(test_input, lines_before_imports=2) == (
+ "\n\nfrom a import b\nfrom c import d\n\nfoo = 'bar'\n"
+ )
+
+
def test_custom_lines_after_import_section() -> None:
"""Test the case where the number of lines to output after imports has been explicitly set."""
test_input = "from a import b\nfoo = 'bar'\n"