File tree 1 file changed +36
-1
lines changed
1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change 19
19
from isort .settings import Config
20
20
21
21
from isort .utils import exists_case_sensitive
22
- from isort .exceptions import FileSkipped , ExistingSyntaxErrors
22
+ from isort .exceptions import FileSkipped , ExistingSyntaxErrors , MissingSection
23
23
from .utils import as_stream , UnreadableStream
24
24
25
25
if TYPE_CHECKING :
@@ -2037,6 +2037,41 @@ def test_custom_sections() -> None:
2037
2037
)
2038
2038
2039
2039
2040
+ def test_custom_sections_exception_handling () -> None :
2041
+ """Ensure that appropriate exception is raised for missing sections"""
2042
+ test_input = "import requests\n "
2043
+
2044
+ with pytest .raises (MissingSection ):
2045
+ isort .code (
2046
+ code = test_input ,
2047
+ default_section = "THIRDPARTY" ,
2048
+ sections = [
2049
+ "FUTURE" ,
2050
+ "STDLIB" ,
2051
+ "DJANGO" ,
2052
+ "PANDAS" ,
2053
+ "FIRSTPARTY" ,
2054
+ "LOCALFOLDER" ,
2055
+ ],
2056
+ )
2057
+
2058
+ test_input = "from requests import get, post\n "
2059
+
2060
+ with pytest .raises (MissingSection ):
2061
+ isort .code (
2062
+ code = test_input ,
2063
+ default_section = "THIRDPARTY" ,
2064
+ sections = [
2065
+ "FUTURE" ,
2066
+ "STDLIB" ,
2067
+ "DJANGO" ,
2068
+ "PANDAS" ,
2069
+ "FIRSTPARTY" ,
2070
+ "LOCALFOLDER" ,
2071
+ ],
2072
+ )
2073
+
2074
+
2040
2075
def test_glob_known () -> None :
2041
2076
"""Ensure that most specific placement control match wins"""
2042
2077
test_input = (
You can’t perform that action at this time.
0 commit comments