Skip to content

Commit

Permalink
test: show output if subprocess fails
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Aug 8, 2024
1 parent 01f2911 commit 26b7f8c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/darker/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from argparse import ArgumentError
from io import BytesIO
from pathlib import Path
from subprocess import PIPE, run # nosec
from subprocess import PIPE, CalledProcessError, run # nosec
from textwrap import dedent
from types import SimpleNamespace
from unittest.mock import ANY, Mock, call, patch
Expand Down Expand Up @@ -969,14 +969,19 @@ def test_stdout_newlines_subprocess(newline):
"""
code = f"import collections{newline}import sys{newline}".encode()
try:

darker_subprocess = run( # nosec
["darker", "--stdout", "--isort", "--stdin-filename=new-file.py", "-"],
input=code,
stdout=PIPE,
check=True,
)
darker_subprocess = run( # nosec
["darker", "--stdout", "--isort", "--stdin-filename=new-file.py", "-"],
input=code,
stdout=PIPE,
check=True,
)

except CalledProcessError as e:
print(e.stdout.decode())
print(e.stderr.decode())
raise
assert darker_subprocess.stdout == code


Expand Down

0 comments on commit 26b7f8c

Please sign in to comment.