@@ -1509,7 +1509,7 @@ def test_alphabetic_sorting():
15091509 "from Products.CMFPlone import utils\n "
15101510 )
15111511 options = {'force_single_line' : True ,
1512- 'force_alphabetical_sort ' : True , }
1512+ 'force_alphabetical_sort_within_sections ' : True , }
15131513
15141514 output = SortImports (file_contents = test_input , ** options ).output
15151515 assert output == test_input
@@ -1523,7 +1523,7 @@ def test_alphabetic_sorting_multi_line():
15231523 """Test to ensure isort correctly handles multiline import see: issue 364"""
15241524 test_input = ("from a import (CONSTANT_A, cONSTANT_B, CONSTANT_C, CONSTANT_D, CONSTANT_E,\n "
15251525 " CONSTANT_F, CONSTANT_G, CONSTANT_H, CONSTANT_I, CONSTANT_J)\n " )
1526- options = {'force_alphabetical_sort ' : True , }
1526+ options = {'force_alphabetical_sort_within_sections ' : True , }
15271527 assert SortImports (file_contents = test_input , ** options ).output == test_input
15281528
15291529
@@ -1608,7 +1608,7 @@ def test_sections_parsed_correct():
16081608def test_alphabetic_sorting_no_newlines ():
16091609 '''Test to ensure that alphabetical sort does not erroneously introduce new lines (issue #328)'''
16101610 test_input = "import os\n "
1611- test_output = SortImports (file_contents = test_input ,force_alphabetical_sort = True ).output
1611+ test_output = SortImports (file_contents = test_input ,force_alphabetical_sort_within_sections = True ).output
16121612 assert test_input == test_output
16131613
16141614 test_input = ('import os\n '
@@ -1618,7 +1618,7 @@ def test_alphabetic_sorting_no_newlines():
16181618 '\n '
16191619 '\n '
16201620 'print(1)\n ' )
1621- test_output = SortImports (file_contents = test_input ,force_alphabetical_sort = True , lines_after_imports = 2 ).output
1621+ test_output = SortImports (file_contents = test_input ,force_alphabetical_sort_within_sections = True , lines_after_imports = 2 ).output
16221622 assert test_input == test_output
16231623
16241624
@@ -1751,3 +1751,34 @@ def test_import_by_paren_issue_375():
17511751 ' Bar,\n '
17521752 ')\n ' )
17531753 assert SortImports (file_contents = test_input ).output == 'from .models import Bar, Foo\n '
1754+
1755+
1756+ def test_function_with_docstring ():
1757+ """Test to ensure isort can correctly sort imports when the first found content is a function with a docstring"""
1758+ add_imports = ['from __future__ import unicode_literals' ]
1759+ test_input = ('def foo():\n '
1760+ ' """ Single line triple quoted doctring """\n '
1761+ ' pass\n ' )
1762+ expected_output = ('from __future__ import unicode_literals\n '
1763+ '\n '
1764+ '\n '
1765+ 'def foo():\n '
1766+ ' """ Single line triple quoted doctring """\n '
1767+ ' pass\n ' )
1768+ assert SortImports (file_contents = test_input , add_imports = add_imports ).output == expected_output
1769+
1770+
1771+ def test_plone_style ():
1772+ """Test to ensure isort correctly plone style imports"""
1773+ test_input = ("from django.contrib.gis.geos import GEOSException\n "
1774+ "from plone.app.testing import getRoles\n "
1775+ "from plone.app.testing import ManageRoles\n "
1776+ "from plone.app.testing import setRoles\n "
1777+ "from Products.CMFPlone import utils\n "
1778+ "\n "
1779+ "import ABC\n "
1780+ "import unittest\n "
1781+ "import Zope\n " )
1782+ options = {'force_single_line' : True ,
1783+ 'force_alphabetical_sort' : True }
1784+ assert SortImports (file_contents = test_input , ** options ).output == test_input
0 commit comments