Skip to content

Commit daa37f4

Browse files
committedOct 7, 2021
Add test for resolve all configs flag
1 parent 59fff6c commit daa37f4

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
 

‎tests/unit/test_main.py

+76
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def test_parse_args():
7979
assert main.parse_args(["--dont-follow-links"]) == {"follow_links": False}
8080
assert main.parse_args(["--overwrite-in-place"]) == {"overwrite_in_place": True}
8181
assert main.parse_args(["--from-first"]) == {"from_first": True}
82+
assert main.parse_args(["--resolve-all-configs"]) == {"resolve_all_configs": True}
8283

8384

8485
def test_ascii_art(capsys):
@@ -1211,3 +1212,78 @@ def main_check(args):
12111212
out, error = main_check([str(git_project0), "--skip-gitignore", "--filter-files"])
12121213

12131214
assert all(f"{str(tmpdir)}{file}" in out for file in should_check)
1215+
1216+
1217+
def test_multiple_configs(capsys, tmpdir):
1218+
setup_cfg = """
1219+
[isort]
1220+
from_first=True
1221+
"""
1222+
1223+
pyproject_toml = """
1224+
[tool.isort]
1225+
no_inline_sort = \"True\"
1226+
"""
1227+
1228+
isort_cfg = """
1229+
[settings]
1230+
force_single_line=True
1231+
"""
1232+
1233+
dir1 = tmpdir / "subdir1"
1234+
dir2 = tmpdir / "subdir2"
1235+
dir3 = tmpdir / "subdir3"
1236+
1237+
dir1.mkdir()
1238+
dir2.mkdir()
1239+
dir3.mkdir()
1240+
1241+
setup_cfg_file = dir1 / "setup.cfg"
1242+
setup_cfg_file.write_text(setup_cfg, "utf-8")
1243+
1244+
pyproject_toml_file = dir2 / "pyproject.toml"
1245+
pyproject_toml_file.write_text(pyproject_toml, "utf-8")
1246+
1247+
isort_cfg_file = dir3 / ".isort.cfg"
1248+
isort_cfg_file.write_text(isort_cfg, "utf-8")
1249+
1250+
import_section = """
1251+
from a import y, z, x
1252+
import b
1253+
"""
1254+
1255+
file1 = dir1 / "file1.py"
1256+
file1.write_text(import_section, "utf-8")
1257+
1258+
file2 = dir2 / "file2.py"
1259+
file2.write_text(import_section, "utf-8")
1260+
1261+
file3 = dir3 / "file3.py"
1262+
file3.write_text(import_section, "utf-8")
1263+
1264+
file4 = tmpdir / "file4.py"
1265+
file4.write_text(import_section, "utf-8")
1266+
1267+
main.main([str(tmpdir), "--resolve-all-configs", "--rp", str(tmpdir)])
1268+
1269+
assert file1.read() == """
1270+
from a import x, y, z
1271+
import b
1272+
"""
1273+
1274+
# assert file2.read() == """
1275+
# import b
1276+
# from a import y, z, x
1277+
# """
1278+
#
1279+
# assert file3.read() == """
1280+
# import b
1281+
# from a import x
1282+
# from a import y
1283+
# from a import z
1284+
# """
1285+
#
1286+
# assert file4.read() == """
1287+
# import b
1288+
# from a import x, y z
1289+
# """

0 commit comments

Comments
 (0)
Please sign in to comment.