mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
give docker a tty output when expecting color
this makes the behavior more consistent with the system language and would help the executable run in a docker container to produce a colored output.
This commit is contained in:
parent
7b868c3508
commit
e58009684c
3 changed files with 32 additions and 3 deletions
|
|
@ -25,3 +25,27 @@ def test_docker_image_hook_via_args(tmp_path):
|
|||
args=('hello hello world',),
|
||||
)
|
||||
assert ret == (0, b'hello hello world\n')
|
||||
|
||||
|
||||
@xfailif_windows # pragma: win32 no cover
|
||||
def test_docker_image_color_tty(tmp_path):
|
||||
ret = run_language(
|
||||
tmp_path,
|
||||
docker_image,
|
||||
'ubuntu:22.04',
|
||||
args=('grep', '--color', 'root', '/etc/group'),
|
||||
color=True,
|
||||
)
|
||||
assert ret == (0, b'\x1b[01;31m\x1b[Kroot\x1b[m\x1b[K:x:0:\n')
|
||||
|
||||
|
||||
@xfailif_windows # pragma: win32 no cover
|
||||
def test_docker_image_no_color_no_tty(tmp_path):
|
||||
ret = run_language(
|
||||
tmp_path,
|
||||
docker_image,
|
||||
'ubuntu:22.04',
|
||||
args=('grep', '--color', 'root', '/etc/group'),
|
||||
color=False,
|
||||
)
|
||||
assert ret == (0, b'root:x:0:\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue