def test_isort_config(monkeypatch, tmpdir, line_length, settings_file, expect): find_project_root.cache_clear() monkeypatch.chdir(tmpdir) (tmpdir / 'pyproject.toml').write( dedent(f"""\ [tool.isort] line_length = {line_length} """)) content = "from module import ab, cd, ef, gh, ij, kl, mn, op, qr, st, uv, wx, yz" config = str(tmpdir / settings_file) if settings_file else None actual = apply_isort(content, Path("test1.py"), config) assert actual == expect
def run_isort(git_repo, monkeypatch, caplog, request): find_project_root.cache_clear() monkeypatch.chdir(git_repo.root) paths = git_repo.add({'test1.py': 'original'}, commit='Initial commit') paths['test1.py'].write('changed') args = getattr(request, "param", ()) with patch.multiple( darker.__main__, run_black=Mock(return_value=[]), verify_ast_unchanged=Mock(), ), patch("darker.import_sorting.isort.code"): darker.__main__.main(["--isort", "./test1.py", *args]) return SimpleNamespace(isort_code=darker.import_sorting.isort.code, caplog=caplog)
def find_project_root_cache_clear(): """Clear LRU caching in :func:`black.find_project_root` before each test""" find_project_root.cache_clear()