Skip to content

Commit

Permalink
test: adjust patching for removed global Black imports
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Oct 19, 2024
1 parent fd942b8 commit b612b54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/darker/tests/test_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from darker.__main__ import main
from darker.command_line import make_argument_parser, parse_command_line
from darker.config import Exclusions
from darker.formatters import black_formatter, ruff_formatter
from darker.formatters import ruff_formatter
from darker.formatters.black_formatter import BlackFormatter
from darker.tests.helpers import flynt_present, isort_present
from darkgraylib.config import ConfigurationError
Expand Down
10 changes: 5 additions & 5 deletions src/darker/tests/test_formatters_black_compatible.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from darker.formatters import black_formatter, ruff_formatter
from darker.formatters import ruff_formatter
from darker.formatters.black_formatter import BlackFormatter
from darker.formatters.ruff_formatter import RuffFormatter
from darkgraylib.testtools.helpers import raises_or_matches
Expand Down Expand Up @@ -79,16 +79,16 @@ def test_run(formatter_class, encoding, newline):
@pytest.mark.parametrize(
"formatter_setup",
[
(BlackFormatter, black_formatter, "format_str"),
(RuffFormatter, ruff_formatter, "_ruff_format_stdin"),
(BlackFormatter, "black.format_str"),
(RuffFormatter, "darker.formatters.ruff_formatter._ruff_format_stdin"),
],
)
@pytest.mark.parametrize("newline", ["\n", "\r\n"])
def test_run_always_uses_unix_newlines(formatter_setup, newline):
"""Content is always passed to Black and Ruff with Unix newlines."""
formatter_class, formatter_module, formatter_func_name = formatter_setup
formatter_class, formatter_func_name = formatter_setup
src = TextDocument.from_str(f"print ( 'touché' ){newline}")
with patch.object(formatter_module, formatter_func_name) as formatter_func:
with patch(formatter_func_name) as formatter_func:
formatter_func.return_value = 'print("touché")\n'

_ = formatter_class().run(src, Path("a.py"))
Expand Down

0 comments on commit b612b54

Please sign in to comment.