Skip to content

Commit

Permalink
test: failing test for isort's skip_glob setting
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Oct 2, 2024
1 parent e854b74 commit 752da52
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/darker/tests/test_main_isort.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Tests for the ``--isort`` option of the ``darker`` command-line interface."""

from textwrap import dedent
# pylint: disable=redefined-outer-name,unused-argument,use-dict-literal

from types import SimpleNamespace
Expand Down Expand Up @@ -81,3 +81,32 @@ def test_isort_option_with_isort_calls_sortimports(run_isort, isort_args):
settings_path=str(run_isort.root),
**isort_args,
)


def test_isort_respects_skip_glob(tmp_path, monkeypatch):
"""Test that Darker respects isort's skip_glob setting."""
# Create a pyproject.toml file with isort skip_glob configuration
configuration = dedent(
"""
[tool.isort]
skip_glob = ['*/conf/settings/*']
filter_files = true
"""
)
(tmp_path / "pyproject.toml").write_text(configuration)
# Create a file that should be skipped
settings_dir = tmp_path / "conf" / "settings"
settings_dir.mkdir(parents=True)
backoffice_py = settings_dir / "backoffice.py"
backoffice_py.write_text("import sys\nimport os\n")

# Run darker with --isort
darker.__main__.main(["--isort", str(settings_dir / "backoffice.py")])
## Strangely, calling isort as a subprocess instead respects the configuration:

Check failure on line 105 in src/darker/tests/test_main_isort.py

View workflow job for this annotation

GitHub Actions / flake8

too many leading '#' for block comment
# import subprocess
# subprocess.run(
# f"isort --settings-path={settings_dir} {settings_dir / 'backoffice.py'}",
# shell=True
# )

assert backoffice_py.read_text() == "import sys\nimport os\n"

0 comments on commit 752da52

Please sign in to comment.