diff options
| author | Timothy Crosley <timothy.crosley@gmail.com> | 2021-11-08 21:21:51 -0800 |
|---|---|---|
| committer | Timothy Crosley <timothy.crosley@gmail.com> | 2021-11-08 21:21:51 -0800 |
| commit | ca084113ad381db3a9497bdabdf5c1de39706cb1 (patch) | |
| tree | 56df5199758cad5a4a858dcacbd79ffb832cc473 /tests | |
| parent | dbd18429cf566e9554842c9322515237bd8efb49 (diff) | |
| download | isort-ca084113ad381db3a9497bdabdf5c1de39706cb1.tar.gz | |
Fixed #1819: Occasional inconsistency with multiple src paths.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/test_main.py | 44 |
1 files changed, 44 insertions, 0 deletions
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 |
