summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--isort/settings.py5
-rw-r--r--tests/unit/test_main.py44
2 files changed, 47 insertions, 2 deletions
diff --git a/isort/settings.py b/isort/settings.py
index d0060d05..45e0ecb9 100644
--- a/isort/settings.py
+++ b/isort/settings.py
@@ -458,13 +458,14 @@ class Config(_Config):
if "src_paths" not in combined_config:
combined_config["src_paths"] = (path_root / "src", path_root)
else:
- src_paths: Set[Path] = set()
+ src_paths: List[Path] = []
for src_path in combined_config.get("src_paths", ()):
full_paths = (
path_root.glob(src_path) if "*" in str(src_path) else [path_root / src_path]
)
for path in full_paths:
- src_paths.add(path)
+ if not path in src_paths:
+ src_paths.append(path)
combined_config["src_paths"] = tuple(src_paths)
diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py
index 66ac0b02..4c16cf51 100644
--- a/tests/unit/test_main.py
+++ b/tests/unit/test_main.py
@@ -1345,3 +1345,47 @@ from a import x, y, z
_, err = capsys.readouterr()
assert f"{str(file6)} Imports are incorrectly sorted and/or formatted" in err
+
+
+def test_multiple_src_paths(tmpdir, capsys):
+ """
+ Ensure that isort has consistent behavior with multiple source paths
+ """
+
+ tests_module = tmpdir / "tests"
+ app_module = tmpdir / "app"
+
+ tests_module.mkdir()
+ app_module.mkdir()
+
+ pyproject_toml = tmpdir / "pyproject.toml"
+ pyproject_toml.write_text(
+ """
+[tool.isort]
+profile = "black"
+src_paths = ["app", "tests"]
+auto_identify_namespace_packages = false
+""",
+ "utf-8",
+ )
+ file = tmpdir / "file.py"
+ file.write_text(
+ """
+from app.something import something
+from tests.something import something_else
+""",
+ "utf-8",
+ )
+
+ for _ in range(10): # To ensure isort has consistent results in multiple runs
+ main.main([str(tmpdir), "--verbose"])
+ out, _ = capsys.readouterr()
+
+ assert (
+ file.read()
+ == """
+from app.something import something
+from tests.something import something_else
+"""
+ )
+ assert "from-type place_module for tests.something returned FIRSTPARTY" in out