Skip to content

Commit

Permalink
test,fix: work around resolve() bug in win py38,39
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Aug 8, 2024
1 parent 228a800 commit 4c75a51
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/darker/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import random
import re
import string
import sys
from argparse import ArgumentError
from io import BytesIO
from pathlib import Path
Expand All @@ -29,7 +30,7 @@
from darker.verification import NotEquivalentError
from darkgraylib.git import WORKTREE, RevisionRange
from darkgraylib.testtools.highlighting_helpers import BLUE, CYAN, RESET, WHITE, YELLOW
from darkgraylib.utils import TextDocument, joinlines
from darkgraylib.utils import WINDOWS, TextDocument, joinlines

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

Expand Down Expand Up @@ -945,12 +946,16 @@ def test_stdout_path_resolution(git_repo, capsys):


@pytest.mark.parametrize("newline", ["\n", "\r\n"], ids=["unix", "windows"])
def test_stdout_newlines(capsysbinary, newline):
def test_stdout_newlines(tmp_path, monkeypatch, capsysbinary, newline):
"""When using ``--stdout``, newlines are not duplicated.
See: https://github.com/akaihola/darker/issues/604
"""
if WINDOWS and sys.version_info < (3, 10):
# See https://bugs.python.org/issue38671
monkeypatch.chdir(tmp_path)
Path("new-file.py").touch()
code = f"import collections{newline}import sys{newline}".encode()
with patch("sys.stdin.buffer.read", return_value=code):

Expand All @@ -963,12 +968,16 @@ def test_stdout_newlines(capsysbinary, newline):


@pytest.mark.parametrize("newline", ["\n", "\r\n"], ids=["unix", "windows"])
def test_stdout_newlines_subprocess(newline):
def test_stdout_newlines_subprocess(tmp_path, monkeypatch, newline):
"""When using ``--stdout``, newlines are not duplicated.
See: https://github.com/akaihola/darker/issues/604
"""
if WINDOWS and sys.version_info < (3, 10):
# See https://bugs.python.org/issue38671
monkeypatch.chdir(tmp_path)
Path("new-file.py").touch()
code = f"import collections{newline}import sys{newline}".encode()
try:

Expand Down

0 comments on commit 4c75a51

Please sign in to comment.