Skip to content

Commit

Permalink
Run import sorting tests in a temporary Git repo
Browse files Browse the repository at this point in the history
This fixes test failures when running tests from a cwd which isn't in a
Git repository.
  • Loading branch information
akaihola committed Apr 13, 2024
1 parent e751ed6 commit 7f5d2d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 1 addition & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ disallow_subclassing_any = False
[mypy-darker.tests.conftest]
disallow_any_unimported = False

[mypy-darker.tests.helpers]
disallow_any_explicit = False

[mypy-darker.tests.*]
disallow_any_decorated = False
disallow_any_explicit = False
disallow_untyped_calls = False
disallow_untyped_defs = False

Expand Down
10 changes: 9 additions & 1 deletion src/darker/tests/test_import_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
from importlib import reload
from pathlib import Path
from textwrap import dedent
from typing import Any, Dict, Optional

import pytest

import darker.import_sorting
from darker.git import EditedLinenumsDiffer
from darker.tests.helpers import isort_present
from darkgraylib.git import RevisionRange
from darkgraylib.testtools.git_repo_plugin import GitRepoFixture
from darkgraylib.utils import TextDocument, joinlines

ORIGINAL_SOURCE = ("import sys", "import os", "", "print(42)")
Expand Down Expand Up @@ -171,7 +173,13 @@ def test_isort_config(monkeypatch, tmpdir, line_length, settings_file, expect):
config=None,
line_length=None,
)
def test_build_isort_args(src, config, line_length, expect):
def test_build_isort_args(
git_repo: GitRepoFixture,
src: Path,
config: Optional[str],
line_length: int,
expect: Dict[str, Any],
) -> None:
"""``_build_isort_args`` returns correct arguments for isort"""
result = darker.import_sorting._build_isort_args(src, config, line_length)

Expand Down

0 comments on commit 7f5d2d5

Please sign in to comment.