-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
342 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Configuration and command line handling.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Data structures configuring Darker and formatter plugin behavior.""" | ||
|
||
from enum import Enum | ||
|
||
|
||
class TargetVersion(Enum): | ||
"""Python version numbers.""" | ||
|
||
PY33 = 3 | ||
PY34 = 4 | ||
PY35 = 5 | ||
PY36 = 6 | ||
PY37 = 7 | ||
PY38 = 8 | ||
PY39 = 9 | ||
PY310 = 10 | ||
PY311 = 11 | ||
PY312 = 12 | ||
PY313 = 13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,33 @@ | ||
"""Test for the `darker.files` module.""" | ||
|
||
import io | ||
from contextlib import redirect_stderr | ||
from pathlib import Path | ||
from unittest.mock import MagicMock, patch | ||
|
||
import pytest | ||
|
||
from darker import files | ||
|
||
|
||
@patch("darker.files.find_user_pyproject_toml") | ||
def test_find_pyproject_toml(find_user_pyproject_toml: MagicMock) -> None: | ||
@pytest.mark.kwparametrize( | ||
dict(start="only_pyproject/subdir", expect="only_pyproject/pyproject.toml"), | ||
Check failure on line 11 in src/darker/tests/test_files.py GitHub Actions / Pylintsrc/darker/tests/test_files.py#L11
|
||
dict(start="only_git/subdir", expect=None), | ||
dict(start="git_and_pyproject/subdir", expect="git_and_pyproject/pyproject.toml"), | ||
Check failure on line 13 in src/darker/tests/test_files.py GitHub Actions / Pylintsrc/darker/tests/test_files.py#L13
|
||
) | ||
def test_find_pyproject_toml(tmp_path: Path, start: str, expect: str) -> None: | ||
"""Test `files.find_pyproject_toml` with no user home directory.""" | ||
find_user_pyproject_toml.side_effect = RuntimeError() | ||
with redirect_stderr(io.StringIO()) as stderr: | ||
# end of test setup | ||
(tmp_path / "only_pyproject").mkdir() | ||
(tmp_path / "only_pyproject" / "pyproject.toml").touch() | ||
(tmp_path / "only_pyproject" / "subdir").mkdir() | ||
(tmp_path / "only_git").mkdir() | ||
(tmp_path / "only_git" / ".git").mkdir() | ||
(tmp_path / "only_git" / "subdir").mkdir() | ||
(tmp_path / "git_and_pyproject").mkdir() | ||
(tmp_path / "git_and_pyproject" / ".git").mkdir() | ||
(tmp_path / "git_and_pyproject" / "pyproject.toml").touch() | ||
(tmp_path / "git_and_pyproject" / "subdir").mkdir() | ||
|
||
result = files.find_pyproject_toml(path_search_start=(str(Path.cwd().root),)) | ||
result = files.find_pyproject_toml(path_search_start=(str(tmp_path / start),)) | ||
|
||
assert result is None | ||
err = stderr.getvalue() | ||
assert "Ignoring user configuration" in err | ||
if not expect: | ||
assert result is None | ||
else: | ||
assert result == str(tmp_path / expect) |
Oops, something went wrong.