Skip to content

Commit

Permalink
Test for non-worktree run_linter() (unsupported)
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Dec 26, 2020
1 parent 9806090 commit 7948518
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/darker/tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
WORKTREE,
EditedLinenumsDiffer,
RevisionRange,
_git_check_output_lines,
git_get_content_at_revision,
git_get_modified_files,
should_reformat_file,
)
from darker.tests.conftest import GitRepoFixture
from darker.tests.helpers import raises_or_matches


@pytest.mark.parametrize(
Expand Down
12 changes: 12 additions & 0 deletions src/darker/tests/test_linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,15 @@ def test_run_linter(git_repo, monkeypatch, capsys, _descr, paths, location, expe
# The test cases also verify that only linter reports on modified lines are output.
result = capsys.readouterr().out.splitlines()
assert result == [line.format(git_repo=git_repo) for line in expect]


def test_run_linter_non_worktree():
"""``run_linter()`` doesn't support linting commits, only the worktree"""
with pytest.raises(NotImplementedError):

run_linter(
"dummy-linter",
Path("/dummy"),
{Path("dummy.py")},
RevisionRange.parse("..HEAD"),
)

0 comments on commit 7948518

Please sign in to comment.