Skip to content

Commit

Permalink
Use lru_cache clear fixture at test module level
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Mar 7, 2024
1 parent e067d72 commit 1ccc840
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
11 changes: 3 additions & 8 deletions src/darker/tests/test_import_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
ORIGINAL_SOURCE = ("import sys", "import os", "", "print(42)")
ISORTED_SOURCE = ("import os", "import sys", "", "print(42)")

pytestmark = pytest.mark.usefixtures("find_project_root_cache_clear")


@pytest.mark.parametrize("present", [True, False])
def test_import_sorting_importable_with_and_without_isort(present):
Expand Down Expand Up @@ -134,14 +136,7 @@ def test_apply_isort_exclude(git_repo, encoding, newline, content, exclude, expe
),
),
)
def test_isort_config(
monkeypatch,
tmpdir,
find_project_root_cache_clear,
line_length,
settings_file,
expect,
):
def test_isort_config(monkeypatch, tmpdir, line_length, settings_file, expect):
"""``apply_isort()`` parses ``pyproject.toml``correctly"""
monkeypatch.chdir(tmpdir)
(tmpdir / "pyproject.toml").write(
Expand Down
9 changes: 4 additions & 5 deletions src/darker/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from darkgraylib.testtools.highlighting_helpers import BLUE, CYAN, RESET, WHITE, YELLOW
from darkgraylib.utils import TextDocument

pytestmark = pytest.mark.usefixtures("find_project_root_cache_clear")


def randomword(length: int) -> str:
"""Create a random string of lowercase letters of a given length."""
Expand All @@ -56,7 +58,7 @@ def test_isort_option_without_isort(git_repo, caplog):


@pytest.fixture
def run_isort(git_repo, monkeypatch, caplog, request, find_project_root_cache_clear):
def run_isort(git_repo, monkeypatch, caplog, request):
"""Fixture for running Darker with requested arguments and a patched `isort`
Provides an `run_isort.isort_code` mock object which allows checking whether and how
Expand Down Expand Up @@ -559,7 +561,6 @@ def test_main(
git_repo,
monkeypatch,
capsys,
find_project_root_cache_clear,
arguments,
newline,
pyproject_toml,
Expand Down Expand Up @@ -662,9 +663,7 @@ def test_main_in_plain_directory(tmp_path, capsys):
"encoding, text", [(b"utf-8", b"touch\xc3\xa9"), (b"iso-8859-1", b"touch\xe9")]
)
@pytest.mark.parametrize("newline", [b"\n", b"\r\n"])
def test_main_encoding(
git_repo, find_project_root_cache_clear, encoding, text, newline
):
def test_main_encoding(git_repo, encoding, text, newline):
"""Encoding and newline of the file is kept unchanged after reformatting"""
paths = git_repo.add({"a.py": newline.decode("ascii")}, commit="Initial commit")
edited = [b"# coding: ", encoding, newline, b's="', text, b'"', newline]
Expand Down

0 comments on commit 1ccc840

Please sign in to comment.